Page 30 - H - 資訊本
P. 30
【資訊本】 肆、活動運用
(二) 程式碼(以第九屆管院祭開幕典禮售票系統為例)
VERSION 5.00
Begin VB.Form Form1
Dim p(999) As String
Dim n As Integer
Dim ms As Integer
Dim nms As Integer
Dim free As Integer
Private Sub Command1_Click()
If Option1.Value = True Then
If Text1.Text <> "" Then
Text1.Text = UCase(Text1.Text)
If Option4.Value = True Then
Call msbuy
Else
Call msrebuy
End If
Else
MsgBox "管院同學請輸入學號", vbRetryCancel + vbInformation, "資料缺失"
End If
Text1.Text = ""
Call Form_Activate
Text1.SetFocus
Else
If Option4.Value = True Then
Call nmsbuy
Else
Call nmsrebuy
End If
Call Form_Activate
End If
End Sub
Sub msbuy()
For i = 1 To n
If Text1.Text = Right(p(i), Len(p(i)) - 1) Then Exit For
Next
If i > n Then
Open "購票人.txt" For Append As #1
Print #1, "1" & Text1.Text
Close
MsgBox "購票成功", vbOKOnly + vbInformation, "成功"
Label4.ForeColor = vbBlue
Label4.Caption = "管院 " & Text1.Text & " 購票成功"
Else
MsgBox "重複購票", vbRetryCancel + vbCritical, "重複!!!"
Label4.ForeColor = vbRed
Label4.Caption = "管院 " & Text1.Text & " 重複購票"
End If
End Sub
Sub msrebuy()
x = 0
Open "購票人.txt" For Output As #1
t = "1" & Text1.Text
27