Find the answer to your Linux question:
Results 1 to 5 of 5
Wasn't there a general windows forum too? maybe not. Stop throwing rocks at me!~ I am taking Visual basic and I am stuck. If anybody could help me out I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    0

    Visual Basic


    Wasn't there a general windows forum too? maybe not. Stop throwing rocks at me!~

    I am taking Visual basic and I am stuck. If anybody could help me out I would appreciate it.

    I cant get my values into the array. I've been crushing this for a couple of hours and now it's crushing me.

    I figured It couldn't hurt to post this in the coffee lounge before I am forced to go join some VB Windows forum to ask for help.

    Dim lblnumbers(6) As Label, txtweight(6) As TextBox
    Dim txtnumbers(6) As TextBox, sngnumbers(6) As Single
    Dim grade() As String, g As Integer = 1, weight() As String
    Dim gval() As Single
    Dim gradetotal As Single = 0, gradedenominator As Single = 0, gradenumerator As Single = 0
    Private Sub btndoit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndoit.Click
    'start the array counter at 1. 0 holds no value! MS should REALLY not have allowed that.
    'redim grade each time we increase the array size in order to get the upperbound
    For i As Integer = 1 To g
    ReDim Preserve grade(i)
    ReDim Preserve weight(i)
    grade(i) = txtnumbers(i).Text
    weight(i) = txtweight(i).Text
    If grade(i) <> "" And grade(i) <> " " And grade(i) <> " " Then
    g += 1
    ElseIf IsNumeric(grade(i)) Then
    MsgBox("You need to enter a letter grade. a+ or B for example.", , "Input education")
    txtnumbers(i).Focus()
    End If
    Next
    g = grade.GetUpperBound(0)
    g -= 1
    For i As Integer = 1 To g
    If grade(i) = "A+" Or grade(i) = "a+" Or grade(i) = "A" Or grade(i) = "a" Then
    gval(i) = 4
    ElseIf grade(i) = "B+" Or grade(i) = "b+" Then
    gval(i) = 3.5
    ElseIf grade(i) = "B" Or grade(i) = "b" Then
    gval(i) = 3
    ElseIf grade(i) = "C+" Or grade(i) = "c+" Then
    gval(i) = 2.5
    ElseIf grade(i) = "C" Or grade(i) = "c" Then
    gval(i) = 2
    ElseIf grade(i) = "D+" Or grade(i) = "d+" Then
    gval(i) = 1.5
    ElseIf grade(i) = "D" Or grade(i) = "d" Then
    gval(i) = 1
    ElseIf grade(i) = "F" Or grade(i) = "f" Then
    gval(i) = 0
    Else
    MsgBox("You need to enter a letter grade. a+ or B for example.", , "Input education")
    txtnumbers(i).Focus()
    End If
    If Val(weight(i)) > 4 And Val(weight(i)) < 1 Then
    MsgBox("Your credit weight was out of bounds. Please enter 1-4 for credit weight " & i, , "Bad credit!")
    txtweight(i).Focus()
    End If
    Next
    For i As Integer = 1 To g
    gradenumerator += gval(i) * Val(weight(i))
    gradedenominator += Val(weight(i))
    Next
    gradetotal = gradenumerator / gradedenominator
    With lstout.Items
    .Add("Yooooooo..... you did good kid! You got a ")
    .Add(gradetotal & " this year.")
    End With
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    lblnumbers(1) = Label1
    lblnumbers(2) = Label2
    lblnumbers(3) = Label3
    lblnumbers(4) = Label4
    lblnumbers(5) = Label5
    lblnumbers(6) = Label6
    txtnumbers(1) = TextBox1
    txtnumbers(2) = TextBox2
    txtnumbers(3) = TextBox3
    txtnumbers(4) = TextBox4
    txtnumbers(5) = TextBox5
    txtnumbers(6) = TextBox6
    txtweight(1) = TextBox7
    txtweight(2) = TextBox8
    txtweight(3) = TextBox9
    txtweight(4) = TextBox10
    txtweight(5) = TextBox11
    txtweight(6) = TextBox12
    '0 is NOT a number that holds a value.
    For index As Integer = 1 To 6
    lblnumbers(index).Text = index & ".) Enter Grade, Then credit hours. "
    Next
    End Sub


    Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
    End
    End Sub

    Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
    For index As Integer = 1 To 6
    txtnumbers(index).Clear()
    txtweight(index).Clear()
    lstout.Items.Clear()

    Next
    End Sub

    Private Sub btnarray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnarray.Click
    lstarray.Items.Add("Letter grade Value Weight")
    For i As Integer = 1 To g
    With lstarray.Items
    .Add(grade(i) & " " & gval(i) & " " & weight(i))
    End With
    Next
    End Sub
    End Class

  2. #2
    Just Joined!
    Join Date
    Apr 2009
    Posts
    0
    nobody? i know 20% of this forum are multi faceted power users that can just solidly write code in VB for hours with nary a manual check.

    I humbly seek your help. My Final is tommorrow.

    perhaps i should have used code tags?

    Code:
    Dim lblnumbers(6) As Label, txtweight(6) As TextBox
    Dim txtnumbers(6) As TextBox, sngnumbers(6) As Single
    Dim grade() As String, g As Integer = 1, weight() As String
    Dim gval() As Single
    Dim gradetotal As Single = 0, gradedenominator As Single = 0, gradenumerator As Single = 0
    Private Sub btndoit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndoit.Click
    'start the array counter at 1. 0 holds no value! MS should REALLY not have allowed that. 
    'redim grade each time we increase the array size in order to get the upperbound
    For i As Integer = 1 To g
    ReDim Preserve grade(i)
    ReDim Preserve weight(i)
    grade(i) = txtnumbers(i).Text
    weight(i) = txtweight(i).Text
    If grade(i) <> "" And grade(i) <> " " And grade(i) <> " " Then
    g += 1
    ElseIf IsNumeric(grade(i)) Then
    MsgBox("You need to enter a letter grade. a+ or B for example.", , "Input education")
    txtnumbers(i).Focus()
    End If
    Next
    g = grade.GetUpperBound(0)
    g -= 1
    For i As Integer = 1 To g
    If grade(i) = "A+" Or grade(i) = "a+" Or grade(i) = "A" Or grade(i) = "a" Then
    gval(i) = 4
    ElseIf grade(i) = "B+" Or grade(i) = "b+" Then
    gval(i) = 3.5
    ElseIf grade(i) = "B" Or grade(i) = "b" Then
    gval(i) = 3
    ElseIf grade(i) = "C+" Or grade(i) = "c+" Then
    gval(i) = 2.5
    ElseIf grade(i) = "C" Or grade(i) = "c" Then
    gval(i) = 2
    ElseIf grade(i) = "D+" Or grade(i) = "d+" Then
    gval(i) = 1.5
    ElseIf grade(i) = "D" Or grade(i) = "d" Then
    gval(i) = 1
    ElseIf grade(i) = "F" Or grade(i) = "f" Then
    gval(i) = 0
    Else
    MsgBox("You need to enter a letter grade. a+ or B for example.", , "Input education")
    txtnumbers(i).Focus()
    End If
    If Val(weight(i)) > 4 And Val(weight(i)) < 1 Then
    MsgBox("Your credit weight was out of bounds. Please enter 1-4 for credit weight " & i, , "Bad credit!")
    txtweight(i).Focus()
    End If
    Next
    For i As Integer = 1 To g
    gradenumerator += gval(i) * Val(weight(i))
    gradedenominator += Val(weight(i))
    Next
    gradetotal = gradenumerator / gradedenominator
    With lstout.Items
    .Add("Yooooooo..... you did good kid! You got a ")
    .Add(gradetotal & " this year.")
    End With
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    lblnumbers(1) = Label1
    lblnumbers(2) = Label2
    lblnumbers(3) = Label3
    lblnumbers(4) = Label4
    lblnumbers(5) = Label5
    lblnumbers(6) = Label6
    txtnumbers(1) = TextBox1
    txtnumbers(2) = TextBox2
    txtnumbers(3) = TextBox3
    txtnumbers(4) = TextBox4
    txtnumbers(5) = TextBox5
    txtnumbers(6) = TextBox6
    txtweight(1) = TextBox7
    txtweight(2) = TextBox8
    txtweight(3) = TextBox9
    txtweight(4) = TextBox10
    txtweight(5) = TextBox11
    txtweight(6) = TextBox12
    '0 is NOT a number that holds a value. 
    For index As Integer = 1 To 6
    lblnumbers(index).Text = index & ".) Enter Grade, Then credit hours. "
    Next
    End Sub
    
    
    Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
    End
    End Sub
    
    Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
    For index As Integer = 1 To 6
    txtnumbers(index).Clear()
    txtweight(index).Clear()
    lstout.Items.Clear()
    
    Next
    End Sub
    
    Private Sub btnarray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnarray.Click
    lstarray.Items.Add("Letter grade Value Weight")
    For i As Integer = 1 To g
    With lstarray.Items
    .Add(grade(i) & " " & gval(i) & " " & weight(i))
    End With
    Next
    End Sub
    End Class

  3. #3
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,532
    dude, try here
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    The Fifth Continent

  4. #4
    Just Joined!
    Join Date
    Apr 2009
    Posts
    0
    thanks.
    I favorited it.
    And I am currently trying here @ VBforums.com. Like this web forum, and the one you recommended, they have an insanely high user count.

    (I'm not allowed to post links here yet.)

  5. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,530
    I did plenty of VB programming in the past, and hated every minute of it! Fortunately, it has been over 5 years since I last had to look at VB code... retch!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •