PDA

View Full Version : need vb.net help


darksoap
11-02-03, 08:50 PM
Private Sub OperationButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OperationButton.Click
Dim strOperation As String
Dim intFirst, intSecond, intAnswer As Integer
strOperation = InputBox("Enter A (add) or S (subtract):", "Operation", "A")
intFirst = Val(InputBox("First number:", "First"))
intSecond = Val(InputBox("Second number:", "Second"))


I need to know how the string will no that it is a A or B
so I can set it in a if then statment.

j@mie
06-04-04, 08:03 AM
here we go

Dim strOperation As String
Dim intFirst, intSecond, intAnswer As Integer
strOperation = InputBox("Enter A (add) or S (subtract):", "Operation", "A")

intFirst = Val(InputBox("First number:", "First"))
intSecond = Val(InputBox("Second number:", "Second"))

Select Case strOperation

Case "A"

'Code to run
intAnswer = intFirst + intSecond
MsgBox(intAnswer)

Case "B"
'Code to run

intAnswer = intFirst - intSecond
MsgBox(intAnswer)

End Select
End Sub

u will have 2 convert stroperation to UPPER or LOWER case as "a" is treated different than "A"

hf