English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I've made an input box and I'm try to have it so that if the user types in say "red" in the input box then 29.99 will show in a text box on the form.

Someone tell me how to do this

2007-03-21 13:44:07 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

I'm definately not talking about a label.

2007-03-21 13:56:49 · update #1

4 answers

First declare a variable as string (for the text of the inputbox)

There is a single step process
Dim GetColor as String = InputBox("What color", Me.Text)
Or a two(2) step process
Dim GetColor as String
GetColor = InputBox("What color", Me.Text)

Then make the If statement

If GetColor.ToLower = "red" then lblResult.Text = "29.99"

OR

If GetColor.ToLower = "red" Then
txtResult.Text = "29.99"
End If

*You do not need the ".ToLower"
*But the text is Case Sensitive

If you want many color's and numbers to be displayed you can use the IfThen...Else...ElseIf...End If STATEMENT

Dim GetColor as String
GetColor = InputBox("What color", Me.Text)

If GetColor = "Red" Then
txtResult.Text = "29.99"
ElseIf GetColor = "Blue"
ltxtResult.Text = "39.99"
End IF

OR

You can use a Case Statement

Dim GetColor as String
GetColor = InputBox("What color", Me.Text)

Select Case GetColor

Case Red
txtResult.Text = "29.99"
Case Blue
txtResult.Text = "39.99"

End Select

2007-03-22 03:17:49 · answer #1 · answered by Anonymous · 0 0

whatever you key-in in an input box is a variable.
first declare the variable:

Dim msg As String

msg = InputBox ("Please enter ....")

Text1.Text = msg

this, whatever you enter will appear in textbox1. however if you want the output to be that "29.99" use the if-else statement:

If msg="red" Then
text1.text=29.99 --> if the datatype is number
End If


do tell me if you still didnt succeed...good luck~

2007-03-21 16:44:50 · answer #2 · answered by farina m 4 · 0 0

I think you are referring to a label.

if txtInput.text = "red"
lblOutput.text = "29.99"
end if

txtInput is the text box name, and lblOutput is the label name


Thats roughly what you need to do. My VB is very rusty....

2007-03-21 13:52:52 · answer #3 · answered by Deasel98 5 · 0 0

the subject is which includes your first line of code. I used your code interior the form open journey with a textbox named txtText and it extremely works completely. examine and revise this line of code. TexMav

2016-11-27 20:50:37 · answer #4 · answered by ? 4 · 0 0

fedest.com, questions and answers