Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy a single character from a string 2

Status
Not open for further replies.

gwar2k1

Programmer
Apr 17, 2003
387
GB
Hey, im used to Turbo Pascal and im getting my feet very wet with vb6 but there are a few things i miss from my pascal code that im stuck with in vb. this is one of those things...

id like to copy a single character from a string (from a text box) for processing. in pascal it'd be nice and simple: snglChar = copy(bigStr, index, 1) with index being where in the string you want to start and 1 being the number of characters to copy.

Is there anything like this inVB? TIA

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
Coming from VBA the Mid function seems to be very similar to what you want to do.

result = Mid("string",startposition, number of characters)
 
cool =D thanks!

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
cool thats great =D works beautifully... however ;) usually when i used the copy, i wanted to find the ordinal value of a character. val is useful for numbers (str1 = int1) but when you use val with a character other than a number, it produces 0. in pascal you cuold do: ord(str) to give you the ascii value of that character.

Anything in VB6? thanks again =)

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
Is the string a number? if so you could try

Dim x As Integer

then use x as the result from the mid statement.
 
its alphanumeric

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
erm...

user inputs: h3ll0

h returns 0
3 returns 3
l returns 0
0 returns 0 (correctly)

instead i want results like

68
33
etc

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
Try
[tt]
dim intTmp as integer

intTmp = asc("A")
[/tt]

This returns 65
 
BEAUTY! thanks so much =D

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top