i need help with changing a text box for a calculator


1. if (textbox3.text = 0) then (textbox.text = 1)

'i need help with that

5 Years
Discussion Span
Last Post by Reverend Jim

A textbox, by definition, contains text. Also keep in mind that

"0" is not equal to 0

The first is a string containing one character, the other is an integer. Everything is stored internally as numbers. The number zero has a value of (you guessed it), 0. However the character "0" has a value (internally) of 30 (unless you are using unicode but let's not worry about that now). How it is interpreted depends on the type of variable used to reference it.

Short version - if you want to check a textbox and replace zero with one you have to do

if (textbox3.text = "0") then (textbox.text = "1")

dude thats not working heres my code, by the way it goes inside a button, thx anyway, could you try agian

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Label2.Text = "*"
        Label3.Text = "*"
        Label1.Text = Val(TextBox1.Text) * Val(TextBox2.Text) * Val(TextBox3.Text)

i'm using vb.net 2008 by the way
i got a syntax error at the "then" in the middle

Edited by syfyguy


never mind i figured it out myself if any one wants it here it is

If (TextBox3.Text = "") Then TextBox3.Text = "1"

dude thats not working

That's because you asked the wrong question.

If TextBox3.Text = "" 

is not the same as comparing it to zero.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.