| View previous topic :: View next topic |
| Author |
Message |
EvilSparx Expert Cheater
Reputation: 0
Joined: 29 Nov 2008 Posts: 175 Location: Behind You!
|
Posted: Mon Dec 01, 2008 2:25 am Post subject: VB 2008 Express Help! |
|
|
I'm working on a translator, all I need is a code.
Its got a box (called textbox1)
A button (called button1)
I want it so that when I type an "A" in the text box, and I click the button, it transforms the "A" into a "1"
eg, if i typed:
"AABAC", when i press the button, I want it to transform into:
"11213"
basicly, i want A to equal 1
B = 2
C = 3
etc.
The problem is, when I type "A", it comes up as "1", but when I type "AB"
instead of comming up as "12", nothing come up at all.
please help me
|
|
| Back to top |
|
 |
FullyAwesome I post too much
Reputation: 0
Joined: 05 Apr 2007 Posts: 4438 Location: Land Down Under
|
Posted: Mon Dec 01, 2008 3:02 am Post subject: |
|
|
i don't know if this is the proper way to do it, but couldn't you loop for the length of the string, so if the string length (of the textbox text) is 5, you loop from 1 to 5. each time you loop you check the next character at a certain spot of the string and use a switch/select case to check the char. i guess this would work.
your problem i'm guessing is because you're checking if the string is equal to A or B, not a combination.
_________________
|
|
| Back to top |
|
 |
AoiMasamune Master Cheater
Reputation: 1
Joined: 14 Jun 2007 Posts: 255
|
Posted: Mon Dec 01, 2008 3:08 am Post subject: |
|
|
Public Function Translate(strInput as String) as String
Dim iStrLength as Integer = strInput.Length
Dim strReturn as String = ""
For X = 0 to iStrLength - 1
Dim chrTemp as Char = strInput.Chars(x)
Select Case chrTemp
Case Is = "A"
strReturn = strReturn & "1"
Case Is = "B"
strReturn = strReturn & "2"
' etc etc...
End Select
Next X
Translate = strReturn
End Function
That should do it I think.
Last edited by AoiMasamune on Mon Dec 01, 2008 1:28 pm; edited 2 times in total |
|
| Back to top |
|
 |
EvilSparx Expert Cheater
Reputation: 0
Joined: 29 Nov 2008 Posts: 175 Location: Behind You!
|
Posted: Mon Dec 01, 2008 3:10 am Post subject: |
|
|
I put the code in the button, and i got a build error?
_________________
Banhammer = Fail
 |
|
| Back to top |
|
 |
FullyAwesome I post too much
Reputation: 0
Joined: 05 Apr 2007 Posts: 4438 Location: Land Down Under
|
Posted: Mon Dec 01, 2008 4:29 am Post subject: |
|
|
that's exactly what i was thinking Aoi.
| EvilSparx wrote: | | I put the code in the button, and i got a build error? |
um do you know how to code in vb.net? that's a function, you call it when you click the button, you don't put the code in the button click event.
if you can't get this done yourself, i'll try to help tomorrow. i'm tired so logging off.
_________________
|
|
| Back to top |
|
 |
|