i need help with changing a text box for a calculator

ex:

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

'i need help with that

 thx

Recommended Answers

All 4 Replies

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.