.NET Practical Slip 1 Q.A

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

  1. Start the program
  2. Design the form with Label, TextBox, and Button
  3. When the Button is clicked, execute a loop
  4. Loop from 1 to a fixed number (e.g., 10 or 100)
  5. Append each number to the TextBox
  6. Display numbers line by line
  7. 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.

Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top