Skip to main content

VB: Countdown

About:
A programme to countdown an amount of seconds, and display a message when the countdown has finished.

Controls:

  • 3  Labels
  • 2  TextBoxes
  • 1  Button


Format: (see image)


Code:


Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label1.Text = ""
        Label2.Text = "Seconds:"
        Label3.Text = "Message:"
        Button1.Text = "Run"
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Interval = Val(TextBox1.Text) * 1000
        Timer1.Start()
        Label1.Text = "Running for " + TextBox1.Text + " seconds.."
        Button1.Enabled = False
        TextBox1.Enabled = False
        TextBox2.Enabled = false
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Timer1.Stop()
        MsgBox(TextBox2.Text)
        Label1.Text = ""
        Button1.Enabled = True
        TextBox1.Enabled = True
        TextBox2.Enabled = True
    End Sub

End Class

Popular posts from this blog

C# Unity: AI Loop Waypoint System

For a looped waypoint system in Unity, attach this C# script to a game object which you want to move. Enter a number in 'size' under Points. This is the number of waypoints which you want the car to hit. The last waypoint does NOT need to be the first waypoint. In Unity, set up waypoint game objects with a collider, with 'is trigger' checked (like below). Script: public List points = new List (); public GameObject currentPoint; public GameObject nextpoint; int current = 0; float speed, defaultSpeed; void Start () {    currentPoint = points[current];    nextpoint = points[current +1];    defaultSpeed = 4.3f;    speed = defaultSpeed; } void Update () {    transform.position = Vector3.MoveTowards(transform.position, nextpoint.transform.position, speed * Time.deltaTime);    if(current < points.Count)    {       currentPoint = points[current];   ...

VB: Alarm Clock

About: A program to replicate an alarm clock. The user enters a time, and the programme will display a MessageBox when the alarm hits. Controls: 4  Labels 1  Textbox 1  Button Format:  (See image) Code: