Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Other Topics > Computer Technical Help
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 11-21-2007, 12:55 AM
BeaucoupFish BeaucoupFish is offline
Senior Member
 
Join Date: Jun 2005
Location: San Francisco
Posts: 723
Default 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
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.