0
我想恢復循環爲1,但僅在.cmdTable(i).caption = txtPrefix.Text + Str(i)中,名稱+數字將恢復爲1,因爲每時間辦理,將得到繼續循環的數量重置回每一個循環中的一個
我想要的STR(I)恢復爲1上的每一次點擊OK
比如我設置表= TABLE +的名稱數字txtEndTable.Text = 5它將從表1循環到表5,以獲得表格的第二個事務名稱= MARK +數字txtEndTable.Text = 5它將生成MARK 6到MARK 10.我想讓MARK 1到MARK 5進行第二筆交易
任何想法會做
Public Sub pAddMultipleTables()
Dim i As Integer
Dim x As Long
Dim lcDefaultTop As Integer
Dim lcLastLeft As Integer
Dim lcMax As Integer
Dim lcSpacing As Integer
Dim lcCurrentTable As Integer
Dim lcStart As Integer
lcSpacing = 1200
lcDefaultTop = 1300
lcMax = 5
lcCurrentTable = 1
lcLastLeft = 240
lcStart = 0
x = 0
With frmTableMap
For i = .cmdTable.ubound + 1 To .cmdTable.ubound + txtEndTable.Text
Load .cmdTable(i)
.cmdTable(i).Visible = True
If lcCurrentTable < lcMax Then
If lcCurrentTable = 1 Then
.cmdTable(i).Top = lcDefaultTop
Else
.cmdTable(i).Top = (.cmdTable(i - 1).Top + .cmdTable(i - 1).Height) + 120
End If
.cmdTable(i).Left = lcLastLeft
lcCurrentTable = lcCurrentTable + 1
' Add to database
.cmdTable(i).ZOrder 0
If optSquare.Value = True Then
.cmdTable(i).ButtonShape = 0
Else
.cmdTable(i).ButtonShape = 4
End If
.cmdTable(i).Caption = txtPrefix.Text + Str(i)
bRS.AddNew
bRS!Name = txtPrefix.Text + Str(i)
bRS!buttonorder = .cmdTable(i).Index
bRS!section = .lblSection.Caption
bRS!ForeColor = .cmdTable(i).ForeColor
bRS!FontSize = .cmdTable(i).Font.Size
bRS!Width = .cmdTable(i).Width
bRS!Height = .cmdTable(i).Height
bRS!Top = .cmdTable(i).Top
bRS!Left = .cmdTable(i).Left
bRS!FontBold = .cmdTable(i).Font.Bold
bRS!FontName = .cmdTable(i).Font.Name
bRS!BackColor = .cmdTable(i).BackColor
bRS!Capacity = txtCapacity.Text
bRS!Type = "1"
If optSquare.Value = True Then
bRS!ButtonShape = 0
Else
bRS!ButtonShape = 4
End If
bRS.Update
ElseIf lcCurrentTable = lcMax Then
If i > 1 Then
.cmdTable(i).Top = (.cmdTable(i - 1).Top + .cmdTable(i - 1).Height) + 200
.cmdTable(i).Left = lcLastLeft
End If
lcLastLeft = (lcLastLeft + .cmdTable(i).Width) + 120
lcCurrentTable = 1
.cmdTable(i).ZOrder 0
If optSquare.Value = True Then
.cmdTable(i).ButtonShape = 0
Else
.cmdTable(i).ButtonShape = 4
End If
.cmdTable(i).Caption = txtPrefix.Text + Str(i)
bRS.AddNew
bRS!Name = txtPrefix.Text + Str(i)
bRS!buttonorder = .cmdTable(i).Index
bRS!section = .lblSection.Caption
bRS!ForeColor = .cmdTable(i).ForeColor
bRS!FontSize = .cmdTable(i).Font.Size
bRS!Width = .cmdTable(i).Width
bRS!Height = .cmdTable(i).Height
bRS!Top = .cmdTable(i).Top
bRS!Left = .cmdTable(i).Left
bRS!FontBold = .cmdTable(i).Font.Bold
bRS!FontName = .cmdTable(i).Font.Name
bRS!BackColor = .cmdTable(i).BackColor
bRS!Capacity = txtCapacity.Text
bRS!Type = "1"
If optSquare.Value = True Then
bRS!ButtonShape = 0
Else
bRS!ButtonShape = 4
End If
bRS.Update
End If
Next
End With
End Sub
-Thanks傢伙
謝謝,但它彈出運行時間錯誤「424」必選對象 –
@ mark.bendal.erica也許你想在第二的第一個和UBOUND使用LBOUND。我不完全確定問題的實質是什麼。 – Danieboy