我想将循环恢复为1,但仅限于.cmdTable(i).caption = txtPrefix.Text + Str(i)所以名称+数字将恢复为1,因为每次进行交易都会得到继续循环次数
我希望每次单击确定时,Str(i)都会恢复为1
例如我设置表的名称= 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 guys
答案 0 :(得分:1)
这可能不是最优雅的解决方案,但这样的事情可能有用。
For i = .cmdTable.lbound + 1 To .cmdTable.ubound + CInt(txtEndTable.Text)
https://msdn.microsoft.com/en-us/library/t9a7w1ac(v=vs.90).aspx