-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
77 lines (61 loc) · 2.02 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Public Class Form1
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim a, b, z As Double
Dim c As Boolean
a = Val(txtoriginal_price.Text)
b = Val(txtAge.Text)
z = calculate(a, b)
lblprice.Text = z
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b, z As Double
Dim answer As Integer
answer = MsgBox("Do you want to repeat the program?", vbQuestion + vbYesNo + vbDefaultButton2, "Repeat?")
a = Val(txtoriginal_price.Text)
b = Val(txtAge.Text)
If answer = vbYes Then
z = calculate(a, b)
Else
MsgBox("Bye!")
End If
End Sub
Public Function calculate(purchasedvalue, age)
Dim x As Double
Dim y As Double
x = Val(age)
If x < 1 Then
y = 1
ElseIf x > 1 And x <= 2 Then
y = 0.8
ElseIf x > 2 And x <= 3 Then
y = 0.6
ElseIf x > 3 And x <= 4 Then
y = 0.4
ElseIf x > 4 And x <= 5 Then
y = 0.2
Else
y = 0
End If
Return purchasedvalue * y
End Function
Private Sub btnadd_database_Click(sender As Object, e As EventArgs) Handles btnadd_database.Click
'This is how an entry gets written in a CSV file
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter("c:\myfolder\Test.csv", True)
file.WriteLine(lblprice.Text)
file.Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Hide()
Form2.Show()
'Module1.main()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Me.Hide()
Form3.Show()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Me.Hide()
Form4.Show()
End Sub
End Class