2013-09-25 53 views
0

我想問一下如何打破數組的行。當我遇到這個問題時,我正在進行問卷調查。我只想做簡直是剛剛突破了代碼的線,所以它不會很長VB 6.0中數組的換行符

我不知道從哪裏開始,所以這裏是我的第一個代碼:

Public Sub showQuestion() 
    Dim letter 
    Dim X As Integer 
    Dim Y As Integer 

Randomize 
question = Array("A programming language originally developed by James Gosling at Sun Microsystems", "A programming language from Microsoft", "Determines when the user wants to do something such as exit the application or begin printing", "Property information", "GUI information and private code") 
answer = Array("Java", "Visual_Basic", "Command_Button", "Property_page", "Form") 

question = Array("Specifies the background color of the control", "Generally, specifies whether or not a control has a border", "Determines whether or not the control can respond to user-generated events", "For controls displaying text, specifies the font (name, style, size, etc.) to be applied to the displayed text") 
answer = Array("BackColor", "BorderStyle", "Enabled", "Font") 

question = Array("Specifies the color of text or graphics to be displayed in the control", "Specifies the height of the control in pixels", "The string value used to refer to the control in code", "Specifies the graphic to be displayed in the control") 
answer = Array("ForeColor", "Height", "Name", "Image") 

qno = Int(Rnd * (UBound(question) + 1)) 
ReDim ans(Len(answer(qno)), 2) 

lblquestion.Caption = question(qno) 

For X = 0 To Len(answer(qno)) - 1 
    ans(X, 1) = Mid$(answer(qno), X + 1, 1) 

Next X 

For Y = 0 To Len(answer(qno)) - 1 
    If ans(Y, 1) = "_" Then 
     ans(Y, 2) = Chr$(32) 
    Else 
     ans(Y, 2) = "*" 
    End If 
Next Y 

loadHint 
End Sub 
+0

不知道你在問什麼,但你可以嘗試添加vbCrLf –

+0

使用_作爲換行符 –

+0

@MarkHall - 怎麼樣,到底是什麼? (對不起) –

回答

2

根據您的說明,您可以通過使用下劃線(_)來打破這一行。

question = Array("A programming language originally developed by James Gosling at Sun Microsystems", _ 
       "A programming language from Microsoft", _ 
       "Determines when the user wants to do something such as exit the application or begin printing", _ 
       "Property information", "GUI information and private code") 

answer = Array("Java", "Visual_Basic", "Command_Button", _ 
       "Property_page", "Form") 
+0

哇,這正是我所需要的。謝謝! –

+0

@EvilMouse不客氣,這也適用於vb.net –

+0

我不知道。我會記住這一點,再次感謝。 –