Amali 3
Amali 3
:______________ Programme:____________________ Course : EE502- VISUAL BASIC PROGRAMMING Assessment: LAB 3: Arrays Learning Outcome: 1. Analyze, design and develop an application and interfacing programming according to the standard procedure of Visual Basic Programming 2. Perform visual basic application and errors solving using debugging and error trapping techniques within a stipulated time frame based on given tasks
Instruction: 1. Student is required to write, compile and run all hands On and Lab Exercise below. Hands On 1:
1. Create a form like the sample with the following controls: 1 labels Change the text and fonts as appropriate 2 label- -Change the text is blank and name to match the coding 1 button- change the text property as appropriate Change the Text property of the form to match the sample
2. Write the coding below: Public Class Form1 Dim test(7) As String declare the array 1 dimensi Dim random1 As Integer Dim random2 As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load test(0) = "kancil" test(1) = "kelisa" test(2) = "Iswara" test(3) = "wira" test(4) = "waja" test(5) = Perdana test(6) = "kenari" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click random = Int(6 * Rnd()) lblone.Text = test(random1) random2 = Int(6 * Rnd()) lbltwo.Text = test(random2) If test(random1) = test(random2) Then MsgBox.Show("Congratulation! You Win a Car") End If End Sub End Class Hands On 2: 1. Create a form like the sample with the following controls: 1 TextBox 2 button- change the text property as appropriate - Change the Text property of the form to match the sample Attached is the code for the class array and the 2 buttons Save and Run your aplication
Public Class Form1 Dim Temperatures() As Single Dim Days As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Prompt, Title As String Dim i As Short Prompt = "Enter the days high temperature." Days = InputBox("How many days?", "Create Array") If Days > 0 Then ReDim Temperatures(Days - 1) For i = 0 To UBound(Temperatures) Title = "Day " & (i + 1) Temperatures(i) = InputBox(Prompt, Title) Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim Result As String Dim i As Short Dim Total As Single = 0 Result = "High temperatures:" & vbCrLf & vbCrLf For i = 0 To UBound(Temperatures) Result = Result & "Day " & (i + 1) & vbTab & _ Temperatures(i) & vbCrLf Total = Total + Temperatures(i) Next Result = Result & vbCrLf & _ "Average temperature: " & Format(Total / Days, "0.0") TextBox1.Text = Result End Sub End Class
Exercise 1 Create a form Student Grade following the table below for Mark & grade Mark 85 above 70-84 60-69 50-59 49 -lowest Grade A B C D E