View Single Post
  #1  
Old 11-20-2007, 02:17 AM
ThaSaltCracka ThaSaltCracka is offline
Senior Member
 
Join Date: Sep 2003
Location: Team Slayer!
Posts: 24,282
Default Anyone good at VB?

I am currently in a VB class and I am confused to all [censored]. Curious if anyone can maybe lend a hand.

Current directions:
Define an array named data() of 30 integers. Assign integer values to the elements of data(i) with Basic statements, not be reading information from an input file. Use a symbolic constant named max for the number 30 of elements. Initialize the first 10 elements of data(i) to i*11; note that VB uses a zero-based lower bound. Initialize the next 10 elements of data(i) to –i, and set the last 10 elements of data(i) to i. When the initialization is complete, print the whole array, prefixed by the string "initial data:" and then the 30 numbers, 10 numbers per output line. Use the previously established method of first concatenating all substrings into a String object, including vbNewlines and blanks for separation.

Here's what I have so far:
Dim a(30) As Integer
Dim i, j As Integer
Dim s As String = "initial data:" & vbNewLine
Const max As Integer = 30

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = a(i) & " "
For i = 0 To 9
a(i) = -11 * i
Next
For i = 10 To 19
a(i) = -i
Next
For i = 20 To 29
a(i) = i
Next
s = s & i & " "
If i Mod 10 = 0 Then
s = s & vbNewLine
End If
MsgBox("Initial data:" & s)
End Sub


I later have to sort the values in non-descending order and print that result. I think I can do that, I am just having problems computing the values and getting them to output in a message box. Any help would be very appreciated!
Reply With Quote