Untitled
unknown
plain_text
2 years ago
1.2 kB
5
Indexable
Imports System.Windows.Forms Public Class NumberInputForm Inherits Form Private label1 As Label Private textBox1 As TextBox Private button1 As Button Public Sub New() label1 = New Label() label1.Text = "Enter a number:" label1.Location = New Drawing.Point(10, 10) textBox1 = New TextBox() textBox1.Location = New Drawing.Point(120, 10) button1 = New Button() button1.Text = "Display" button1.Location = New Drawing.Point(10, 40) AddHandler button1.Click, AddressOf DisplayButton_Click Me.Controls.Add(label1) Me.Controls.Add(textBox1) Me.Controls.Add(button1) Me.Size = New Drawing.Size(250, 120) End Sub Private Sub DisplayButton_Click(ByVal sender As Object, ByVal e As EventArgs) Dim number As Integer If Integer.TryParse(textBox1.Text, number) Then MessageBox.Show("You input: " & number) Else MessageBox.Show("Invalid input. Please enter a valid number.") End If End Sub Public Shared Sub Main() Application.Run(New NumberInputForm()) End Sub End Class
Editor is loading...