English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

題目:
樂透彩~包8個數字,請列出此8個數字的所有組合。

請VB程式撰寫高手或有經驗的人指導一下!!
(這次期中考能不能過就看這一關了)

2006-10-21 18:38:24 · 3 個解答 · 發問者 Perry 1 in 電腦與網際網路 程式設計

10/22補充問題內容:
版本為Visual Studio 2005
感謝W J S大大的指導,可惜平台不同....

2006-10-22 08:06:54 · update #1

回答puppy:
失敗。偵錯時很多地方2005版的並不能通過。

2006-10-22 15:18:05 · update #2

回答puppy:
Call 包牌(-1, S, A)
上述語法中的變數『S』已在指派值之前透過傳址方式傳遞,所以有可能會在執行階段產生『null』參考例外狀況。請您看看是哪邊出了問題。

2006-10-24 15:05:02 · update #3

3 個解答

'版本:VB6.0Private Sub Command1_Click()    Dim I As Integer, J As Integer, A(7) As Integer, B(1 To 45) As Boolean, S As String, T As Integer        '輸入號碼    For I = 0 To 7        Do          J = Int(Val(InputBox("請輸入第" & I + 1 & "個號碼")))          '樂透好像是1~45,沒在玩,自己修正吧XD          If J >= 1 And J <= 45 Then             If B(J) = False Then Exit Do          End If        Loop        A(I) = J: B(J) = True    Next    '由小到大排序    For I = 0 To 6        For J = I To 7            If A(I) > A(J) Then T = A(I): A(I) = A(J): A(J) = T        Next    Next    Cls    Call 包牌(-1, S, A)End SubSub 包牌(ByVal D As Integer, ByRef S As String, ByRef A() As Integer)    Dim I As Integer        For I = D + 1 To UBound(A)        S = S & A(I) & ","        If UBound(Split(S, ",")) = 6 Then Print Left$(S, Len(S) - 1)        Call 包牌(I, S, A)        S = Left$(S, InStrRev(S, ",", Len(S) - 1))    NextEnd Sub

2006-10-21 21:16:57 · answer #1 · answered by W.J.S. 7 · 0 0

丟到VB.NET裡頭就會幫你轉換....

2006-10-23 09:31:51 補充:
謝謝WJS吧
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub

Sub 包牌(ByVal D As Integer, ByRef S As String, ByRef A() As Integer)
Dim I As Integer

For I = D + 1 To UBound(A)
S = S & A(I) & ","
If UBound(Split(S, ",")) = 6 Then
TextBox1.Text = TextBox1.Text & Microsoft.VisualBasic.Left(S, Len(S) - 1) & vbNewLine
End If

Call 包牌(I, S, A)
S = Microsoft.VisualBasic.Left(S, InStrRev(S, ",", Len(S) - 1))
Next
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer, j As Integer, A(7) As Integer, B(45) As Boolean
Dim S As String, T As Integer

'輸入號碼
For i = 0 To 7
Do
j = Int(Val(InputBox("請輸入第" & i + 1 & "個號碼")))
'樂透好像是1~45,沒在玩,自己修正吧XD
If j >= 1 And j <= 45 Then
If B(j) = False Then Exit Do
End If
Loop
A(i) = j : B(j) = True
Next
'由小到大排序
For i = 0 To 6
For j = i To 7
If A(i) > A(j) Then T = A(i) : A(i) = A(j) : A(j) = T
Next
Next
'Cls()
Call 包牌(-1, S, A)
End Sub
End Class

2006-10-27 12:37:48 補充:
不必管他,執行下去就可以了.真的很在意就改成Dim S As String = "", T As Integer

2006-10-23 05:31:51 · answer #2 · answered by puppy 5 · 0 0

順便請問一下@@? Split函數要怎麼用啊?

2006-10-21 21:30:14 · answer #3 · answered by Anderson Meng 3 · 0 0

fedest.com, questions and answers