Connecting a button to 2 separate text boxes. One a number, the other a text.

Tim 60 Reputation points
2024-01-14T01:56:24.67+00:00

On Visual Basic I'm trying to get this button to operate. In textbox one I enter a number. Let's use 70. If that number is greater than 65, I want the textbox two to display "Good".

Thanks!

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,780 questions
{count} votes

Accepted answer
  1. Azar 26,185 Reputation points MVP
    2024-01-14T02:40:36.75+00:00

    Hey Tim Give this a try

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ' Check if the entered number in TextBox1 is greater than 65
        If IsNumeric(TextBox1.Text) AndAlso CInt(TextBox1.Text) > 65 Then
            ' If true, display "Good" in TextBox2
            TextBox2.Text = "Good"
        Else
            ' If false, clear TextBox2
            TextBox2.Text = ""
        End If
    End Sub
    
    
    

    If this helps kindly accept the answer thanks much.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.