Dorine Mae Dorine Mae - 6 months ago 10
Vb.net Question

Show text that depends on a number in a TextBox

I'm not sure what went wrong here:

Dim xapp As Integer = 20000
Dim xnet As Integer
Dim ans As String

xnet = NETPAYTextBox.Text
ans = AppstatusTextBox.Text

If (xapp < xnet) Then
ans = "Approved"
Else
ans = "Pending"
End If


It suppose to show "Approved" if the value of the NETPAYTextBox is greater than 20000 or show "Pending" if the value of the NETPAYTextBox is lower than 20000.

Answer

This should do the trick. It makes sure you have an Integer and if so do the comparison and set the text depending on the outcome...

    Dim xnet As Integer = 0

    AppstatusTextBox.Text = CStr(If(Integer.TryParse(NETPAYTextBox.Text, xnet) AndAlso 20000 < xnet, "Approved", "Pending"))