Dorine Mae Dorine Mae - 2 years ago 69 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"
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 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