Doing a project and need some help please with codeing. here is what it looks like.
http://img300.imageshack.us/img300/5946/code4du.jpg
And here is the code I have.
Dim Names() As String
Dim intArrayCounter As Integer
Private Sub cmdAdd_Click()
Dim i As Integer
On Error GoTo ErrMsg
'save upper limit to array names()
intArrayCount = UBound(Names)
'Resize Names() if latest element holds a value
If Names(UBound(Names)) <> "" Then
intArrayCount = intArrayCount + 1
MsgBox "Incresing the Array Size"
ReDim Preserve Names(intArrayCount) As String
End If
'Scroll through array until empty element is found
For i = 0 To UBound(Names)
If Names(i) = "" Then
'validate textbox has content
If txtName.Text <> "" Then
Names(i) = txtName.Text
txtName.Text = ""
txtName.SetFocus
Call cmdPrint_Click
Exit For
Else
Err.Raise 10999
End If
End If
Next
End Sub
ErrMsg
MsgBox "Please enter a name in the " & vbCrLf & " appropraite space provided." & vbCrLf & vbCrLf & _
"The following error occured: vbCrLf & Err.Description, vbExclamation + vbOKOnly, vbCrLf & Error Message: Error Number(" & Err.Number & ")"
Exit Sub
End Sub
Private Sub cmdClear_Click()
Dim Names(0) As String
frmArrayDisplay.Cls
txtName.SetFocus
End Sub
Private Sub cmdExit_Click()
Exit Sub
End Sub
Private Sub cmdPrint_Click()
Dim i As Integer
frmArrayDisplay.Cls
If UBound(Names) <= 25 Then
For i = 0 To UBound(Names)
If Names(i) <> "" Then
If i < 9 Then
If i < 1 Then
frmArrayDisplay.Print " "
End If
frmArrayDisplay.Print " " & " " & i + 1&; ". " & Names(i)
Else
frmArrayDisplay.Print " " & i + 1&; ". " & Names(i)
End If
End If
Next
Else
ReDim Preserve Names(25)
MsgBox " No more than 26 names can be entered " & vbCrLf & _
"Because the form will not hold the list." & vbCrLf & "A mazimum of 26 names can be entered.", vbExclamation = vbOKOnly, "Error Message"
End If
txtName = SetFocus
End Sub
Private Sub Form_Activate()
Unload frmArrayDisplay
txtName.Text = ""
txtName.SetFocus
End Sub
Private Sub form_Load()
ReDim Names(0) As String
End Sub
Private Sub Form_resize()
frmArrayDisplay.Width = 30
frmArrayDisplay.Height = 58
End Sub
Private Sub txtName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdAdd_Click
End If
End Sub