Results 1 to 2 of 2

Thread: VB question

  1. #1
    Newbie
    Join Date
    Nov 2007
    Posts
    1

    VB question

    private Sub xMainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim inputscore As Integer
    Dim score As Integer = 1
    Dim scoreCount As Integer
    Dim average As String
    Dim prompt As Double
    Dim title As Integer


    Do While inputscore <> String.Empty
    If score >= 0 Then
    score = inputscore + score
    scoreCount = scoreCount + 1
    Else
    MessageBox.Show(Text, "Total Score", MessageBoxButtons.OK, _
    MessageBoxIcon.Information)
    End If

    inputscore = InputBox(prompt, title, "")
    average = score / scoreCount
    Loop

    I need a little help with this code, want to be able to enter a score from 0 to 10 and then add the total and average out the score. I have total number input box, avg score input and a total score input box. Can someone direct me into the right direction.

    Thanks

  2. #2
    Maximum Bitrate galvitron's Avatar
    Join Date
    Mar 2007
    Location
    Socal
    Posts
    719
    Your description is not really clear but I will try

    Dim done as Boolean = false
    Dim totalScore as integer = 0
    Dim NumberOfScores as integer = 0

    Dim inputStr as string = ""

    While Not done

    'Get a score
    inputStr = InputBox()

    'If they enter a blank string, exit loop
    If inputStr = "" Then
    Exit While
    End If

    'Check for valid integer
    Dim i as integer = -1
    Try
    i = Convert.ToInt32(inputStr)
    Catch
    Continue While
    End Try

    'Check for between 1 and 10
    If i < 0 Or i > 10 Then
    Continue While
    End If

    totalScore += i
    numberOfScores += 1

    'Show current average
    MsgBox("Average is now: " & (totalScore/numberOfScores).ToSting)

    'Go to next input
    End While
    2006 Lancer Evolution IX MR In-Dash PC Project - WIP

    Planning:
    [----------] 100%
    Purchasing:
    [----------] 90%
    Installation/Fab/Assembly (Revised v2):
    [----------] 90%


Similar Threads

  1. Replies: 2
    Last Post: 05-02-2006, 05:15 PM
  2. Complete Newbie Question.
    By DomesticImport in forum Newbie
    Replies: 15
    Last Post: 07-07-2005, 06:24 PM
  3. VB question.
    By Arathranar in forum Road Runner
    Replies: 5
    Last Post: 06-21-2005, 12:11 PM
  4. FM Card Question....
    By Superbike1k in forum Car Audio
    Replies: 1
    Last Post: 05-16-2005, 09:03 AM
  5. VB Frontend
    By rjstephens in forum Software & Software Development
    Replies: 7
    Last Post: 10-05-2002, 01:22 AM

Bookmarks

Posting Permissions

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