Dorine Mae Dorine Mae - 1 year ago 96 Question show a text depends on the answer

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"
ans = "Pending"
End If

It suppose to show "Approved" if the value of the NETPAYTextBox is greater than 20000 or else it will show "Pending" if the value of the NETPAYTextBox is lower than 20000. Please help, it's simple but I'm really confused. Thanks by the way.

Answer Source

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"))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download