Private Sub CommandButton1_Click()
Dim T$, Q$, Brr, V&
T = Trim([A1]): V = Val(TextBox1.Value): If V = 0 Or T = "" Then Exit Sub
ReDim Brr(1 To V, 1 To 1)
Q = StrReverse(Mid(Val(StrReverse(T & "1")), 2))
T = Replace(T, Q, "")
For i = 0 To V - 1: Brr(i + 1, 1) = T & (Val(Q) + i): Next
[A1].Resize(V) = Brr
End Sub作者: aassddff736 時間: 2024-2-17 17:02
Private Sub CommandButton1_Click()
Dim T$, Q$, Brr, V&, L%
'↑宣告變數
T = Trim([A1]): V = Val(TextBox1.Value): If V = 0 Or T = "" Then Exit Sub
'↑令T變數是[A1]儲存格去除頭尾後的新字串,令V變數是文字窗輸入值轉化成的數值
'如果V變數是0 或T變數是空字元,就結束程式執行
Intersect(Me.UsedRange, [A:A]).Offset(1).ClearContents
'↑令[A2]開始以下的儲存格清除內容
ReDim Brr(1 To V, 1 To 1)
'↑宣告Brr變數是二維空陣列
Q = Val(StrReverse(T & "1")): Q = StrReverse(Mid(Q, 2)): L = Len(Q)
'↑令Q變數是 T字串最後的連續數字串,令L變數是Q變數的字元數
T = Replace(T, Q, "")
'↑令T變數變成至換掉Q變數後的新字串
For i = 0 To V - 1: Brr(i + 1, 1) = T & Application.Text(Val(Q) + i, String(L, "0")): Next
'↑設順迴圈!令i變數從0 到V變數-1,將迴圈新字串寫入Brr陣列中
[A1].Resize(V) = Brr
'↑令從[A1]儲存格開始向下擴展V變數個儲存格範圍,以Brr陣列值寫入
End Sub作者: aassddff736 時間: 2024-2-19 10:52