hey guys i am builing a program "alis score". what it does is calculate your GCSE grade and give a score for that...(total subjects divide by 9). I got like max. 9 subjects in my program and consists of three form.. I have finished all the programming but i got stuck in my last form.. I DONT KNOW HOW TO SHOW ALL THE INFORMATION FROM FORM 2 IN FORM 3. I GOT 1 LIST BOX AND THREE LABELS IN FORM 3.HERES THE CODE FROM 2ND FORM.. CAN ANYONE GIVE A DETAIL CODE FOR MY THIRD FORM?????????PLZZZ

Dim newName As String '
Dim newNumber As Integer
Dim Grades(0 To 8) As String
Dim Points(0 To 8) As Integer
Dim Totalscore As Integer
Dim i As Integer
Dim choice As Integer
Dim Alisscore As Double

Private Sub cmdReturnToMenu_Click()
Close #1
frmFrontPage.Show
FrmUserDetails.Hide
End Sub

Private Sub CmdSubmit_Click()
newName = txtName.Text
newNumber = Val(txtStudentNumber.Text)
If txtStudentNumber.Text < 1000 Or txtStudentNumber.Text > 9999 Then GoTo NumberError

If List1 = List2 Or List2 = List3 Or List3 = List4 Or List4 = List5 Or List5 = List6 Or List6 = List7 Or List7 = List8 Or List8 = List9 Then GoTo Subjecterror

Write #1, newName, newNumber, List1, lstg1, List2, lstg2, List3, lstg3, List4, lstg4, List5, lstg5, List6, lstg6, List7, lstg7, List8, lstg8, List9, lstg9, lblAlisScore
txtName.Text = ""
txtStudentNumber.Text = ""

ErrorResume:
Exit Sub

NumberError:
MsgBox ("Number between 1000 and 9999")
txtStudentNumber.Text = ""
GoTo ErrorResume

Subjecterror:
MsgBox ("Same Subjects selected")
List1 = ""
List2 = ""
List3 = ""
List4 = ""
List5 = ""
List6 = ""
List7 = ""
List8 = ""
List9 = ""
GoTo ErrorResume
End Sub

Private Sub Form_Load()
Open "FileStudentNumber.txt" For Append As #1
Open "Alisscore.txt" For Input As #2
For i = 0 To 8
Input #2, Grades(i), Points(i)
lstg1.AddItem Grades(i)
lstg2.AddItem Grades(i)
lstg3.AddItem Grades(i)
lstg4.AddItem Grades(i)
lstg5.AddItem Grades(i)
lstg6.AddItem Grades(i)
lstg7.AddItem Grades(i)
lstg8.AddItem Grades(i)
lstg9.AddItem Grades(i)
Next i

Close #2
lbldate.Caption = Format(Date, "dd/mm/yyyy")

End Sub

Private Sub lstg1_Click()
choice = lstg1.ListIndex
lblp1.Caption = Points(choice)
End Sub

Private Sub lstg2_Click()
choice = lstg2.ListIndex
lblp2.Caption = Points(choice)
End Sub

Private Sub lstg3_Click()
choice = lstg3.ListIndex
lblp3.Caption = Points(choice)
End Sub

Private Sub lstg4_Click()
choice = lstg4.ListIndex
lblp4.Caption = Points(choice)
End Sub

Private Sub lstg5_Click()
choice = lstg5.ListIndex
lblp5.Caption = Points(choice)
End Sub

Private Sub lstg6_Click()
choice = lstg6.ListIndex
lblp6.Caption = Points(choice)
End Sub

Private Sub lstg7_Click()
choice = lstg7.ListIndex
lblp7.Caption = Points(choice)
End Sub

Private Sub lstg8_Click()
choice = lstg8.ListIndex
lblp8.Caption = Points(choice)
End Sub

Private Sub lstg9_Click()
choice = lstg9.ListIndex
lblp9.Caption = Points(choice)
End Sub
Private Sub Showtotal_Click()
Totalscore = Val(lblp1.Caption) + Val(lblp2.Caption) + Val(lblp3.Caption) + Val(lblp4.Caption) + Val(lblp5.Caption) + Val(lblp6.Caption) + Val(lblp7.Caption) + Val(lblp8.Caption) + Val(lblp9.Caption)
Alisscore = FormatNumber(Totalscore / 9, 1)
Showtotal.Caption = Totalscore
lblAlisScore.Caption = Alisscore
End Sub
Private Sub txtStudentNumber_KeyPress(Key As Integer)
If Key < Asc("0") Or Key > Asc("9") Then Key = 0
End Sub

Private Sub txtName_KeyPress(Key As Integer)
If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", UCase(Chr$(Key))) = 0 Then Key = 0
End Sub

I believe I responded to your PM with the answer. If so please post your final answer here and mark this thread as solved.

Your instruction doesnot indicate what i meant...

Does anyone know how to validate the list box in this program? The validation i used in this program is NOT RIGHT..If List1 = List2 Or List2 = List3 Or List3 = List4 Or List4 = List5 Or List5 = List6 Or List6 = List7 Or List7 = List8 Or List8 = List9 Then GoTo Subjecterror


It doesnot state if LISt1 = List3..List2 =4 etc i dont know to use the loop function here..so plzz help

I DONT KNOW HOW TO SHOW ALL THE INFORMATION FROM FORM 2 IN FORM 3. I GOT 1 LIST BOX AND THREE LABELS IN FORM 3

It might be a good idea to add a module to your program and declare some Public Arrays there in that module.

Public Grades(0 To 8) As String
Public Points(0 To 8) As Integer

Then you wouldn't have to use those Dim Statements on the second form. And your data would be accessible in all three of your forms.

Does anyone know how to validate the list box in this program?

I assume that you don't want any data to match.

If you used Public Arrays or Public Variables in a new module or even the variables as you have them currently declared, your program would execute quicker and also be easier to understand, if you would work with variables rather than values on controls on your form.

That's not a good habit to get into. I've seen programs where the programmer stored all his data he worked with in hidden text boxes on the form. What a terror to figure out! Try finding the data in hidden controls.

If you store the values you wish to place in the list in a variable array, you could use a loop to cycle through the array to check for data redunancy (repeating data values) and then warn the user to enter a unique value for that list, if redundant data is found.

Private Sub CheckData()
Dim i as Integer, intCounter as Integer
Dim blnIdenticalFound as Boolean
blnIdenticalFound = False

Dim Grades (0 to 8) as String  ' Grades (8) is sufficient
for i = 0 to 8
     for intCounter = 0 to 8
         if Grades(i) = Grades(intCounter) then
             MsgBox "Warning, Identical Grade", "Warning", vbInformation
             exit for
         End if

         if blnFound then
             Exit Sub
         End if
     next intCounter
next i

End Sub
Be a part of the DaniWeb community

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