Include

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Henk ten Bos

    Include

    Hi all,

    is there anyone who knows of a way in VB6 to have include-files (like in C:
    include <include.h>) ?

    thanks!
    Henk


  • Auric__

    #2
    Re: Include

    On Tue, 14 Oct 2003 22:25:05 +0200, "Henk ten Bos" <henktb_1@xs4al l.nl>
    wrote:
    [color=blue]
    >Hi all,
    >
    >is there anyone who knows of a way in VB6 to have include-files (like in C:
    >include <include.h>) ?
    >
    >thanks!
    >Henk[/color]

    Totally unnecessary. If you add a file to a project the normal way (or
    manually add it to the project file), it's automatically included
    everywhere. (If you really want, you can always write modules and give
    them an extension of .bi - that's the old QuickBasic extension for
    "Basic Include" - but you'll still have to add them in normally.)
    --
    auric "underscore " "underscore " "at" hotmail "dot" com
    *****
    I'd love to, but I left my body in my other clothes.

    Comment

    • Henk ten Bos

      #3
      Re: Include

      Well.... I do have a valid reason to want some sort of an include file.
      I'd like to have a number of language dependent constants in my project and
      (to avoid having to declare them globally) would like to include them using
      a language-file.

      Example for the same function using English and Dutch:

      Public Sub Message()
      Private Const cText as String = "This is a message"
      ........
      Call MsgBox(cText)
      End Sub

      And

      Public Sub Message()
      Private Const cText as String = "Dit is een melding"
      ........
      Call MsgBox(cText)
      End Sub

      I would like to implement this using:

      Public Sub Message()
      <<include language.h>>
      ........
      Call MsgBox(cText)
      End Sub

      So I can compile two versions of the software, just by replacing language.h
      with the appropriate file.

      I know I can just include one or more files in my project, but then I would
      have to make all the constants global, right. That's not what i want!

      thanks,
      Henk


      "Auric__" <not.my.real@em ail.address> wrote in message
      news:jlnoovoc2g qb7imtd4pq6i9jm [email protected] om...[color=blue]
      > On Tue, 14 Oct 2003 22:25:05 +0200, "Henk ten Bos" <henktb_1@xs4al l.nl>
      > wrote:
      >[color=green]
      > >Hi all,
      > >
      > >is there anyone who knows of a way in VB6 to have include-files (like in[/color][/color]
      C:[color=blue][color=green]
      > >include <include.h>) ?
      > >
      > >thanks!
      > >Henk[/color]
      >
      > Totally unnecessary. If you add a file to a project the normal way (or
      > manually add it to the project file), it's automatically included
      > everywhere. (If you really want, you can always write modules and give
      > them an extension of .bi - that's the old QuickBasic extension for
      > "Basic Include" - but you'll still have to add them in normally.)
      > --
      > auric "underscore " "underscore " "at" hotmail "dot" com
      > *****
      > I'd love to, but I left my body in my other clothes.[/color]


      Comment

      • Steve Gerrard

        #4
        Re: Include

        You should look into resource strings. You use the function
        LoadResString(S tringID) to return strings from a resource file. Resource files
        can be "internationali zed", that is, they can have different language versions
        for each string. The appropriate one is selected based on the "locale", that is,
        the language setting of the computer the program is running on.

        Use the Add In Manager to load the VB 6 Resource Editor, then click on Tools,
        Resource Editor. You can then build string tables for as many languages as you
        like. You can use the strings for messages, and also for menus and captions if
        you want.

        "Henk ten Bos" <henktb_1@xs4al l.nl> wrote in message
        news:3f8d9b6e$0 $58709$e4fe514c @news.xs4all.nl ...[color=blue]
        > Well.... I do have a valid reason to want some sort of an include file.
        > I'd like to have a number of language dependent constants in my project and
        > (to avoid having to declare them globally) would like to include them using
        > a language-file.
        >
        > Example for the same function using English and Dutch:
        >
        > Public Sub Message()
        > Private Const cText as String = "This is a message"
        > .......
        > Call MsgBox(cText)
        > End Sub
        >
        > And
        >
        > Public Sub Message()
        > Private Const cText as String = "Dit is een melding"
        > .......
        > Call MsgBox(cText)
        > End Sub
        >
        > I would like to implement this using:
        >
        > Public Sub Message()
        > <<include language.h>>
        > .......
        > Call MsgBox(cText)
        > End Sub
        >
        > So I can compile two versions of the software, just by replacing language.h
        > with the appropriate file.
        >
        > I know I can just include one or more files in my project, but then I would
        > have to make all the constants global, right. That's not what i want!
        >
        > thanks,
        > Henk
        >
        >[/color]


        Comment

        • Henk ten Bos

          #5
          Re: Include

          ok, thanks. I looked at this solution, but "hoped" that there was a more
          simple one (like include-files). To add and maintain the strings with
          resource files is a bit tedious.

          thanks !
          Henk

          "Steve Gerrard" <notstevegerrar [email protected]> wrote in message
          news:SqudnQH9eI [email protected]. ..[color=blue]
          > You should look into resource strings. You use the function
          > LoadResString(S tringID) to return strings from a resource file. Resource[/color]
          files[color=blue]
          > can be "internationali zed", that is, they can have different language[/color]
          versions[color=blue]
          > for each string. The appropriate one is selected based on the "locale",[/color]
          that is,[color=blue]
          > the language setting of the computer the program is running on.
          >
          > Use the Add In Manager to load the VB 6 Resource Editor, then click on[/color]
          Tools,[color=blue]
          > Resource Editor. You can then build string tables for as many languages as[/color]
          you[color=blue]
          > like. You can use the strings for messages, and also for menus and[/color]
          captions if[color=blue]
          > you want.
          >
          > "Henk ten Bos" <henktb_1@xs4al l.nl> wrote in message
          > news:3f8d9b6e$0 $58709$e4fe514c @news.xs4all.nl ...[color=green]
          > > Well.... I do have a valid reason to want some sort of an include file.
          > > I'd like to have a number of language dependent constants in my project[/color][/color]
          and[color=blue][color=green]
          > > (to avoid having to declare them globally) would like to include them[/color][/color]
          using[color=blue][color=green]
          > > a language-file.
          > >
          > > Example for the same function using English and Dutch:
          > >
          > > Public Sub Message()
          > > Private Const cText as String = "This is a message"
          > > .......
          > > Call MsgBox(cText)
          > > End Sub
          > >
          > > And
          > >
          > > Public Sub Message()
          > > Private Const cText as String = "Dit is een melding"
          > > .......
          > > Call MsgBox(cText)
          > > End Sub
          > >
          > > I would like to implement this using:
          > >
          > > Public Sub Message()
          > > <<include language.h>>
          > > .......
          > > Call MsgBox(cText)
          > > End Sub
          > >
          > > So I can compile two versions of the software, just by replacing[/color][/color]
          language.h[color=blue][color=green]
          > > with the appropriate file.
          > >
          > > I know I can just include one or more files in my project, but then I[/color][/color]
          would[color=blue][color=green]
          > > have to make all the constants global, right. That's not what i want!
          > >
          > > thanks,
          > > Henk
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • J French

            #6
            Re: Include

            On Thu, 16 Oct 2003 09:35:21 +0200, "Henk ten Bos"
            <henktb_1@xs4al l.nl> wrote:
            [color=blue]
            >ok, thanks. I looked at this solution, but "hoped" that there was a more
            >simple one (like include-files). To add and maintain the strings with
            >resource files is a bit tedious.
            >[/color]
            There are several ways of skinning this cat

            One that has worked well for me is to have a sort of INI file for each
            language that contains a 'Lexicon'

            Command1.Captio n = Lex( "Click Here" )

            Lex() is a function that looks for :-

            Click Here=Druck Hier

            If it does *not* find the English then it adds the English to the Lex
            file and returns ... the English

            If it is there then it returns the 'other language'

            I also provided an editor, so users could do their own translation

            If you do not fancy having files hanging around, then I guess you
            could append the data to the EXE - or use Resource Strings for release
            - in which case you just have one string to read

            Another alternative is to write a small App to tinker with the
            contents of your .VBP file

            Yet another is to have ALL the files in your App but to use
            Conditional Compilation eg:

            #Const Flag = False

            Private Sub Command1_Click( )
            #If Flag Then
            Me.Print "Hullo"
            #Else
            Me.Print "No Way"
            #End If
            End Sub

            Personally I am not that keen on Conditional Compilation.

            Yet another way is to have (say) two Classes that contain the data

            Dim L as cLex
            Select Case Language
            Case enEnglish : Set L = New clexEnglish
            Case enGerman : Set L = New clexGerman
            ....
            End Select

            Command1.Captio n = L.Click_Me

            For this you will need to look at the 'Implements' key word

            Personally I would go for the Lexicon in a file approach, as I prefer
            to be able to read my own code
            - and the 'file' can be stored in the EXE for release versions

            Comment

            • Auric__

              #7
              Re: Include

              On Thu, 16 Oct 2003 09:35:21 +0200, "Henk ten Bos" <henktb_1@xs4al l.nl>
              wrote:
              [color=blue]
              >ok, thanks. I looked at this solution, but "hoped" that there was a more
              >simple one (like include-files). To add and maintain the strings with
              >resource files is a bit tedious.
              >
              >thanks !
              >Henk[/color]

              How about something like this?
              Sub loadStrings()
              #Const english = True
              #Const dutch = False
              #If english Then
              Open "english" For Input As 1
              #Else
              Open "dutch" For Input As 1
              #End If
              ' code to read in your strings here
              Close 1
              End Sub

              This way you can have separate files with your language strings
              contained within, and just write code to input the strings from whatever
              file gets opened.
              --
              auric "underscore " "underscore " "at" hotmail "dot" com
              *****
              Capital Punishment: the income tax.

              Comment

              Working...