How annoying is visual basic?

TheJkWhoSaysNi

One of Freddy's beloved
Joined
Dec 23, 2003
Messages
187
Very.

This is just silly, I have to write a ceasar cipher. I've done the hard part. It works perfectly.

Unless I try to clear the text box the text is going to before I put something into it!

Code:
Cipher.Text = "" ' This is the problem.
    
    For i = 1 To Len(PlainText.Text)
    
    Letter = Mid$(PlainText.Text, i, 1)
    
    IntLetter = Asc(Letter)
    
    If IntLetter >= 65 And IntLetter <= 122 Then
    	If IntLetter >= 65 And IntLetter <= 90 Then
    	Uppercase = True
    	Else: Uppercase = False
    	
       End If
     
       
    End If
    
    IntLetter = IntLetter + Shift.Value
    
    If Uppercase = True Then
    	If IntLetter > 90 Then
    	IntLetter = IntLetter - 26
    	End If
    	End If
    	
    If Uppercase = False Then
    	If IntLetter > 122 Then
    	IntLetter = IntLetter - 26
    End If
    End If
    
    Cipher.Text = Cipher.Text + Chr(IntLetter)
    
    Next i

It works great without the "Cipher.Text = "" " at the beginning but obviously it adds the text onto whatever is already there.

Anyway, I digress. Does anyone know how to fix this problem?
 

Doh_boy

Part of the furniture
Joined
Dec 22, 2003
Messages
1,007
Would it work if you put " " in? Maybe VB don't like being empty?

:/

I really need to look into VB Further!

Just looked around and you should be able to do it! :s

strange, what error does it return?
 

TheJkWhoSaysNi

One of Freddy's beloved
Joined
Dec 23, 2003
Messages
187
Nevermind. As I suspected it was a silly error. I had my text box names muddled up. So it was clearing it.. but then it was checking the length of the wrong text box for the for loop.
 

Doh_boy

Part of the furniture
Joined
Dec 22, 2003
Messages
1,007
At least it wasn't a missing semi-colon! The amount of time I nearly damaged College/uni equipement because of that. :D
 

Ixoth

One of Freddy's beloved
Joined
Apr 9, 2004
Messages
1,952
Dont mock VB :) I've done my programs mostly with VB - including the ARR's Crafter Helper Util - which is btw work in progress..
 

Shovel

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,350
For future Textbox.Clear() might be a more elegant way of doing it. Assuming that VB.NET actually has the same object functions as C#.NET...
 

strangely brown

Can't get enough of FH
Joined
Dec 22, 2003
Messages
54
Or how about (for VB6):-

Cipher.Text = VbEmpty

Could be wrong though - Been years since I attempted any VB...

Regs,
SB
 

Danya

Fledgling Freddie
Joined
Dec 23, 2003
Messages
2,466
Ixoth said:
Dont mock VB :) I've done my programs mostly with VB - including the ARR's Crafter Helper Util - which is btw work in progress..
VB deserves mockery. :eek:
 

Oidche

Fledgling Freddie
Joined
Jun 22, 2004
Messages
41
Doh_boy said:
At least it wasn't a missing semi-colon! The amount of time I nearly damaged College/uni equipement because of that. :D

Jeez, these are SO easy to spot. Try forgetting a curly bracket instead! ;)
 

Danya

Fledgling Freddie
Joined
Dec 23, 2003
Messages
2,466
Oidche said:
Jeez, these are SO easy to spot. Try forgetting a curly bracket instead! ;)
Editors with bracket matching are your friend. ;)
 

Users who are viewing this thread

Top Bottom