Question Trouble Translating Letters To Numerical Values

vertical horizons

New member
Joined
Nov 4, 2010
Messages
3
Programming Experience
1-3
I want my code to look at a textbox to determine which letter is in it, & assign a numerical value to a second textbox, based on what letter is in the first textbox.

Here is the code:

If Form20.txtGrade1.text = "C" Then
Form20.txtGrade1a.text = "4"
End If


The problem is that, when I step through the code, I can see that Form20.txtGrade1.text DOES EQUAL "C", but my code skips over the part that says Form20.txtGrade1a.text = "4". Instead, if I hover over that part, I can read Form20.txtGrade1a.text = " ".

When I do not step through the code, and just run it, I see the two textboxes, with the first one containing the C, and the second one is just blank.

What am I doing wrong?
 
I don't work with Forms that much, but i never include the form name. Try just txtGrade1.text.

Also, your if statement is case sensitive. If you are entering a "c" instead of a "C" your code will skip over the txtGrade1a.Text = "4" portion.

I always use .ToLower when doing this type of work. You could also use an Or statement to check for both cases.

VB.NET:
If txtGrade1.Text.ToLower="c" Then
    txtGrade1a.Text = "4"
End If
OR
VB.NET:
If txtGrade1.Text = "C" OR txtGrade1.Text = "c" Then
   txtGrade1a.Text = "4"
End If
 
Returns a copy of this System.String converted to lowercase, using the casing rules of the current culture.

Meaning it takes whatever string you have and it returns it but using all lower case letters.

"BLAH" becomes "blah"


And this might help you, as I know I use it all the time. F12.

Place your cursor over anything hit F12 and it will either take you to where you declared the variable/function/sub/whatever, or if it is something that is apart of the framework it will take you to a page that describes what it does.
 
Returns a copy of this System.String converted to lowercase, using the casing rules of the current culture.

Meaning it takes whatever string you have and it returns it but using all lower case letters.

"BLAH" becomes "blah"...

Thanks.
That makes sense.

...And this might help you, as I know I use it all the time. F12.

Place your cursor over anything hit F12 and it will either take you to where you declared the variable/function/sub/whatever, or if it is something that is apart of the framework it will take you to a page that describes what it does.

I will try the "F12" tonight.
Sounds like that could really come in handy.
 
Back
Top