Using Visual basic 2008 is the following possible if so how?

0.....................299..................F
300...................349..................D
350...................399..................C
400...................449..................B
450...................500..................A

using two one dimensional arrays (min pts as int and Grade as string) in parallel,
can the range of 0 to 299 return F, 300 to 349 return D ...etc?

Absolutely. Come up with an idea and we'll help you fine tune it.

Dim strA(0tO3,0tO3,0tO3)As String
strA(0,0)="0"
strA(0,1)="299"

stra(0,2)="F"
For intX = 0To 3
For intY = 0To 3
For intZ = 0To3
Print strA(Intx,intY,intZ)
Next
Next
Next

## All 7 Replies

Absolutely. Come up with an idea and we'll help you fine tune it.

Absolutely. Come up with an idea and we'll help you fine tune it.

I am a real neophyte to programming. I came up with the following code I displys a grade only for 0, 300, 350, 400, 450 the rest of the time the message box appears. I do not know how to make it range so 0 to 299 returns F etc.. My thoughts have been posssible add 49 to each number then for the range X to X + 49 return corresponding grade but that omits 500 thought possible you could put a range in the array like 0-299, 300-349 etc in fact tried it and it did not work but was not sure if I had the syntax correct.

``````' displays a grade associated with a score
Dim intPoints() As Integer = {0, 300, 350, 400, 450}
Dim strGrades() As String = {"F", "D", "C", "B", "A"}
Dim intSearchForPoints As Integer
Dim intSubScript As Integer

' Aasigns score entered in txtPoints
Integer.TryParse(txtPoints.Text, intSearchForPoints)

' search intPoints array for score
'search entire array or until the score is found
Do Until intSubScript = intPoints.Length _
OrElse intSearchForPoints = intPoints(intSubScript)
intSubScript = intSubScript + 1

Loop

' determine wether the grade was found
If intSubScript < intPoints.Length Then
Else
MessageBox.Show("Invalid Points", _
"The Professor", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information)

End If
txtPoints.Focus()

End Sub
End Class
``````

Dim strA(0tO3,0tO3,0tO3)As String
strA(0,0)="0"
strA(0,1)="299"

stra(0,2)="F"
For intX = 0To 3
For intY = 0To 3
For intZ = 0To3
Print strA(Intx,intY,intZ)
Next
Next
Next

I suggest to change your loop a little bit to find when the suplied value is less than the upper limit of the segment:

``````Do Until intSubScript = intPoints.Length _
OrElse intSearchForPoints < intPoints(intSubScript)
intSubScript = intSubScript + 1
Loop``````

Then to obtain the 'previous' grade

``````If intSubScript <=  intPoints.Length Then

Hope this helps

I suggest to change your loop a little bit to find when the suplied value is less than the upper limit of the segment:

``````Do Until intSubScript = intPoints.Length _
OrElse intSearchForPoints < intPoints(intSubScript)
intSubScript = intSubScript + 1
Loop``````

Then to obtain the 'previous' grade

``````If intSubScript <=  intPoints.Length Then

Hope this helps

Yes it worked thank you vry much the only thing now is it returns an answer for entry above 500 above 500 it should return invalid points.
Thanks again for the help

Maybe you can extent your array to place the Integer.MaxValue as the last element in the intPoint array and an extra element int the strgrades for those values.

Hope this helps

Thanks for all the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.