.NET Practical Slip 2 Q A

This VB.NET Windows Forms program demonstrates how to move the text “Pune University” continuously from left to right and vice versa using a Timer control. It helps students understand animation and control movement in Windows Forms.

Slip 2 Q.A) Write a VB.Net program to move the text “Pune University” continuously from Left to Right and Vice Versa. 15 Marks

Answer:

Algorithm / Logic

  1. Start the application.
  2. Design a Windows Form and place a Label control with the text “Pune University” on it.
  3. Add a Timer control to the form and set its Interval property.
  4. Initialize a direction variable to control the movement of the label.
  5. Start the Timer when the form loads or when a button is clicked.
  6. On each Timer tick:
    • Move the label towards the right by increasing its Left property.
    • When the label reaches the right boundary of the form, change the direction.
    • Move the label towards the left by decreasing its Left property.
  7. Repeat the process continuously to achieve left-to-right and right-to-left movement.
  8. Stop the application.

Source Code

Public Class Form1
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        If Label1.Left >= Me.Width Then
            Label1.Left = -100
        Else
            Label1.Left = Label1.Left + 10
        End If
    End Sub
End Class

FAQ Section

Q1. What is VB.NET?
VB.NET is an object-oriented programming language used to develop Windows, web, and database applications on the .NET framework.

Q2. What is a Windows Forms application?
It is a type of .NET application used to create graphical user interface (GUI) based desktop programs.

Q3. Which control is used to display text in this program?
A Label control is used to display the text.

Q4. What is the purpose of the Timer control?
The Timer control is used to execute code repeatedly at a fixed time interval.

Q5. What does the Interval property of the Timer specify?
It specifies the time in milliseconds between two consecutive Timer ticks.

Spread the love

Leave a Comment

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

Scroll to Top