VB6 & Strings
Hi all,
man, this may seem unbelievably simple, but,
i still cant do it, so here i am...
How does one manipulate strings in Visual Basic 6?
if I have a = "Alpha", can i change the first
caracter, "A" to "K", like, for example,
A(1) = "B" ????
I know i cant do it this way, but there should be a way
of doing this kind of things...
I''m used to the way Turbo Pascal 7 handles strings, so...
thx a lot all,
Hugo Ferreira
You can''t access one char directly in the string. I think that the only way you can do it is with something like this :
A = "K" & Mid(A, 2)
"Mid" is a function that returns a string with all the caraters from the position 2 (the second parameter) to the end. I know, this is not a universal solution but because strings, in vb, are not arrays like in C, you can''t acces the different position directly.
A = "K" & Mid(A, 2)
"Mid" is a function that returns a string with all the caraters from the position 2 (the second parameter) to the end. I know, this is not a universal solution but because strings, in vb, are not arrays like in C, you can''t acces the different position directly.
alexk7
Do this:
sText = "Alpha"
Mid$(sText, 1, 1) = "K"
If you want to process lots of characters in a string individually, I would recommend converting the string to a byte array and then you can do stuff like ByteArray(5) = Asc("F")
Later.
sText = "Alpha"
Mid$(sText, 1, 1) = "K"
If you want to process lots of characters in a string individually, I would recommend converting the string to a byte array and then you can do stuff like ByteArray(5) = Asc("F")
Later.
August 08, 2000 08:30 AM
try:
a= "K" & mid("Alpha",2,len("alpha")-1)
Mid(string, start[, length])
hmmm thats not very easy ...let me think...i dont know
a= "K" & mid("Alpha",2,len("alpha")-1)
Mid(string, start[, length])
hmmm thats not very easy ...let me think...i dont know
quote: Original post by pentium3id
Hi all,
man, this may seem unbelievably simple, but,
i still cant do it, so here i am...
How does one manipulate strings in Visual Basic 6?
if I have a = "Alpha", can i change the first
caracter, "A" to "K", like, for example,
A(1) = "B" ????
I know i cant do it this way, but there should be a way
of doing this kind of things...
I''m used to the way Turbo Pascal 7 handles strings, so...
thx a lot all,
Hugo Ferreira
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement