# 關於VB的河內塔程式～高手請入（20點）

QQ但是

### 4 個解答

• W.J.S.
Lv 7
1 0 年前
最佳解答

Dim K(4), C(2), S(2), N%, V%, W%, H%, Q%, P%, B%Private Sub Form_Load()Dim I%, R%Width = 7800Height = 3300AutoRedraw = 1DrawStyle = 3Q = 2200P = 300R = PFor I = 0 To 2    C(I) = R    Line (R, P)-(R + Q, P + Q), , B    R = R + P + QNextR = Q - PFor I = 4 To 0 Step -1    Set K(I) = Controls.Add("Vb.Shape", "K" & I)    With K(I)         .Left = (Q - R) / 2 + P: .Top = (Q - R) / 2 + P: .Height = R: .Width = R: .Visible = 1         .Shape = 1: .FillStyle = 0: .FillColor = QBColor(I + 1): .ZOrder    End With    S(0) = I & "," & S(0)    R = R - PNextEnd SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Dim I%, J%B = 0If Button = 1 Then    For I = 0 To 2        If X > C(I) And X < C(I) + Q Then           If Y > P And Y < Q Then Exit For        End If    Next        If I < 3 Then       If S(I) <> "" Then            J = InStr(S(I), ",")            N = Left(S(I), J - 1)            If X > K(N).Left And X < K(N).Left + K(N).Width Then               If Y > K(N).Top And Y < K(N).Top + K(N).Height Then                  W = X                  H = Y                  B = 1                  V = I                  If J = Len(S(I)) Then                     S(I) = ""                  Else                     S(I) = Mid(S(I), J + 1)                  End If               End If            End If       End If    End IfEnd IfEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 1 And B Then   K(N).Move K(N).Left + X - W, K(N).Top + Y - H   W = X: H = YEnd IfEnd SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)Dim I%If Button = 1 And B Then    For I = 0 To 2        If X > C(I) And X < C(I) + Q Then           If Y > P And Y < Q Then Exit For        End If    Next    If I > 2 Then       I = V    Else       If S(I) <> "" Then          If Int(Left(S(I), InStr(S(I), ",") - 1)) < N Then I = V       End If    End If    K(N).Move (Q - K(N).Width) / 2 + C(I), (Q - K(N).Height) / 2 + P    S(I) = N & "," & S(I)    B = 0End IfEnd Sub

• 1 0 年前

大大可以敎一下媽^^

• 1 0 年前

你幾年級

我三年級而以這麼簡單

(f1)+)(01)= 001

go;krm kt; knr ql;n pqn pn

eo ]rn[w

rjqo [