469,282 Members | 1,743 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

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
Jul 17 '05 #1
6 13185
On Tue, 14 Oct 2003 22:25:05 +0200, "Henk ten Bos" <he******@xs4all.nl>
wrote:
Hi all,

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

thanks!
Henk


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.
Jul 17 '05 #2
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__" <no*********@email.address> wrote in message
news:jl********************************@4ax.com...
On Tue, 14 Oct 2003 22:25:05 +0200, "Henk ten Bos" <he******@xs4all.nl>
wrote:
Hi all,

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

thanks!
Henk


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.

Jul 17 '05 #3
You should look into resource strings. You use the function
LoadResString(StringID) to return strings from a resource file. Resource files
can be "internationalized", 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" <he******@xs4all.nl> wrote in message
news:3f***********************@news.xs4all.nl...
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

Jul 17 '05 #4
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" <no*************@comcast.net> wrote in message
news:Sq********************@comcast.com...
You should look into resource strings. You use the function
LoadResString(StringID) to return strings from a resource file. Resource files can be "internationalized", 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" <he******@xs4all.nl> wrote in message
news:3f***********************@news.xs4all.nl...
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


Jul 17 '05 #5
On Thu, 16 Oct 2003 09:35:21 +0200, "Henk ten Bos"
<he******@xs4all.nl> wrote:
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.

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.Caption = 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.Caption = 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
Jul 17 '05 #6
On Thu, 16 Oct 2003 09:35:21 +0200, "Henk ten Bos" <he******@xs4all.nl>
wrote:
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


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.
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

43 posts views Thread by steve | last post: by
60 posts views Thread by Derrick Coetzee | last post: by
9 posts views Thread by zolli | last post: by
5 posts views Thread by David Mathog | last post: by
1 post views Thread by ya man | last post: by
14 posts views Thread by Jon Rea | last post: by
7 posts views Thread by Giancarlo Bassi | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.