|
-
Apr 20th, 2010, 09:16 AM
#30
Thread Starter
Lively Member
Re: good old arrays
here is my code, I receive an error message "variable not defined"
Option Explicit
Dim Element As Integer
'~~~ Creating the type
Private Type Student
strName As String
intMark As Integer
End Type
Private Sub cmdAddRecord_Click()
'~~~ Checking. This should be done first !
If Val(txtStudentMark.Text) <= 0 Then
MsgBox "student mark cannot be less than zero. Please re-enter it"
Exit Sub
ElseIf Val(txtStudentMark.Text) > 100 Then
MsgBox "student mark cannot be greater than 100. Please re-enter it"
Exit Sub
End If
Element = Element + 1
ReDim Preserve strName(1 To Element) <---------------error msg "variable not defined"
ReDim Preserve intMark(1 To Element)
strName(Student) = txtStudentName.Text
intMark(Student) = txtStudentMark.Text
lstNames.AddItem Student(Element).strName
lstMarks.AddItem Student(Element).intMark
End Sub
I thought it was though above? Have I declared the datatypes correctly?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|