String data type internat representation
Hello everybody
I was wondering what the internal encoding of a String data type is in VB6. Is it Unicode or ACSII?
Also, in my application I store strings embedded in the code. Is there a better way? Something like a string table in Visual C++ 6.0.
thx, in advance
George Papadopoulos
Re: String data type internat representation
Re: String data type internat representation
There isn't a direct "String Table" functionality in Visual Basic. There may be an add-in which allows it. People talk alot about MZTools, although I haven't used it before, and really don't know about it at all.
Phreak
Re: String data type internat representation
You can use text = StrConv(text, vbUnicode)
to store strings that are 2 byte Unicode.
Re: String data type internal representation
ok. But can I store these Unicode converted strings in the default VB6 String type or do I need to create an array of my own?
Re: String data type internat representation
Looks like string type works. :wave:
VB Code:
Option Explicit
Private Sub Form_Load()
Dim a As String
Dim b As String
a = "test"
b = StrConv(a, vbUnicode) ' is just "t" at this point
a = StrConv(b, vbFromUnicode)
MsgBox a ' prints "test"
End Sub
I started with B as a variant, and changed it back into a string.
Re: String data type internat representation
Yes it is possible!
Use AddIn Manager to load Resource Editor. Create a resource file. Here you can store your strings etc. exactly in a table type format and it is embedded into your exe. You won't need any external tool.
Re: String data type internat representation
Doh. I'd never bothered with Resource Files in VB, I assumed they were different than their C++ counter-parts.
Meh, that's my stretch of experimentation for you.
Phreak
Re: String data type internat representation
From what I`ve got running dglienna`s code I have these comments :
a) The value of b is actually t e s t . At least that is what I get in Debug mode, using Debug.Print.
b) It seems that the MsgBox function cannot handle correctly the two-byte Unicode string. That is why it prints a single 't'.
Am I wrong somewhere?