I have a vb problem, can someone help me?

missmandy
06-30-2005, 11:11 AM
Hello I want to program something that when the user clicks on the command button, the name will be changed from Jane Smith into enaJ Smith. When the user clicks it again, it changes back to Jane Smith. Does anyone know how to do that? Thanks!

Please post in the default forum font. It's easiest to read. Thanks :)

TeraBlight
06-30-2005, 11:20 AM
Use InStr() to find the position of the " "
Use Left$() to isolate the first name
Create an empty string s


Loop over the characters of the first name (For i = 1 To Len())


Get the character number i (using Mid$())
Prepend the character to s (s = newChar & s)
End Loop


Isolate the surname, using Mid$(), and concatenate with s (which now holds the firstName backwards)


Usage info and examples for the string functions above are in the MSDN.

Mathijsken
06-30-2005, 11:26 AM
Well, I do and I'll explain it in a minute. First I'll have to say that title such as yours are much to vague for any one of us to be attracted too. The more specific your title, the more specific people will try to help you!

Anyway: you'd first want two controls on your form: a button and a text field. If those are present then your ButtonName_Click() code should do the folowing:
1) Split the string in the text field (eg Jane Smith) using the Split function into smaller parts. The delimiter or in non-terms, the string that will be used as a 'split point' will have to be a space in our case. So: Split(Text1.Text, " ")
2) Store the array of strings the split function returns in a variable. Like this:
Dim strArray() as String
strArray = Split(....)
3) Alter the order of characters inside the first element of the array. To do this is suggest you'd use the StrReverse function

If you didn't understand a word what I said, do ask for help.

EDIT: there you've already got two answers ;) I love double posts!

Mathijsken

HardCode
06-30-2005, 12:52 PM
Also, please note that these suggestions won't be followed by code example, as homework answers are prohibited by the pg. However, with MSDN and the above logic-flow, it should be a snap to figure out.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum