#7
|
|||
|
|||
Re: Anyone good at VB?
You were told to declare max as a constant, but you didn't use it to initialise the array:
Const max As Integer = 30 Dim a(max) As Integer Scope: you have declared the string s globally and again locally. You should lose all the global declarations, make them all local. Also, note that in VB at least, the following declaration makes i a variant, and j an integer Dim i, j As Integer Either do Dim i As Integer, j As Integer or better yet Dim i As Integer Dim j As Integer Actually, you are not even using the second variable. Finally, from your supplied code, I cannot imagine you are getting much output. Why not populate your string as you loop through setting the array values? Also, please note spacing and indentation for awesome readability [img]/images/graemlins/smile.gif[/img] (only shows up using .... sorry) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ....Const max As Integer = 30 ....Dim a(max) As Integer ....Dim i As Integer ....Dim s As String ....s = "initial data:" & vbNewLine ....For i = 0 To 9 ........a(i) = i * -11 ........s = s & a(i) & " " ....Next ....s = s & vbNewLine ....For i = 10 To 19 ........a(i) = -i ........s = s & a(i) & " " ....Next ....s = s & vbNewLine ....For i = 20 To 29 ........a(i) = i ........s = s & a(i) & " " ....Next ....s = s & vbNewLine ....Call MsgBox(s) End Sub |
|
|