Slip-1 Question (a) is a common VB.NET Windows Forms practical problem asked in college exams. In this program, students learn how to display numbers continuously in a TextBox when a Button is clicked.
Slip-1 Q. A) Write a VB.NET program to display the numbers continuously in a TextBox by clicking on a Button.
Answer:
Algorithm / Logic
- Start the program
- Design the form with Label, TextBox, and Button
- When the Button is clicked, execute a loop
- Loop from 1 to a fixed number (e.g., 10 or 100)
- Append each number to the TextBox
- Display numbers line by line
- End the program
Source Code (VB.NET)
Public Class Form1
Dim Counter As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Counter = 0
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Counter = Counter + 1
TextBox1.Text = Counter
End Sub
End Class
Output
When the user clicks the Display Numbers button, the TextBox shows:
1
2
3
4
5
6
7
8
9
10
Numbers appear continuously one below another inside the TextBox.
FAQ Section
Q1. Why is Multiline property used in TextBox?
It allows the TextBox to display multiple lines of text.
Q2. What is the use of vbCrLf?
It moves the cursor to the next line in the TextBox.
Q3. Can we display more numbers?
Yes, change the loop limit from 1 To 10 to any number.