Option Explicit
Option Base 0
Dim a(100) As Integer
Dim j(100) As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e, f, g, h, k As Integer
Dim t1, t2 As Integer
Private Sub Command1_Click() '開始
t1 = CInt(Text1) 'text1的資料轉成數字
t2 = CInt(Text2) 'text2的資料轉成數字
'判斷是否含特別號
If Option1.Value = False Then
d = 6 '不含特別號
ElseIf Option2.Value = False Then
d = 7 '含特別號
End If
'指定陣列的值以text1和text2為最小及最大值
For b = t1 To t2
a(b) = b
Next b
j(0) = 0
f = 0
Adodc1.Recordset.AddNew '新增一筆空白記錄
Call prog(a, j, f, t2, d, e) '呼叫副程式
End Sub
Private Sub Command2_Click() '離開
Unload Me
MsgBox "謝謝、祝您中獎", vbOKOnly
End Sub
Private Sub Command3_Click() '清空
If Command3.Caption = "修改" Then
Text1.Visible = True
Text2.Visible = True
Command4.Visible = True
Text1.SetFocus
Command3.Caption = "清空"
Command1.Visible = False
ElseIf Command3.Caption = "清空" Then
Text1.Text = ""
Text1.SetFocus
End If
Text2.Text = ""
End Sub
Private Sub Command4_Click() '數字確定
'判斷text1和text2是否有資料
If Text1.Text = "" Then
MsgBox "錯誤,必須有資料", vbOKOnly
Text1.SetFocus
ElseIf Text2.Text = "" Then
Text2.SetFocus
MsgBox "錯誤,必須有資料", vbOKOnly
Else:
Text1.Visible = False
Text2.Visible = False
Command1.Visible = True
Command3.Caption = "修改"
Command4.Visible = False
End If
End Sub
Private Sub Form_Load()
End Sub
Private Sub Option1_GotFocus()
Text9.Visible = True
Label9.Visible = True
End Sub
Private Sub Option2_GotFocus()
Text9.Visible = False
Label9.Visible = False
End Sub
Public Sub prog(a, j, f, t2, d, e)
e = j(f)
f = f + 1
If f = d Then
For k = 1 + e To (t2 - d + f)
 j(f) = k
 For g = 1 To d
  h = j(g)
  Adodc1.Recordset.Fields(g) = a(h) '填資料到資料庫
 Next g
 Adodc1.Recordset.AddNew '新增一筆空白記錄
Next k
Else
For k = 1 + e To (t2 - d + f)
 j(f) = k
 Call prog(a, j, f, t2, d, e) '呼叫副程式
Next k
End If
f = f - 1
End Sub
幫我看看那理出錯了好嘛、寫到沒咖啡可喝了。
文章標籤
全站熱搜
創作者介紹
創作者 vbqa 的頭像
vbqa

小吳 VBQA 程式設計討論

vbqa 發表在 痞客邦 留言(1) 人氣(47)