Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Customizing array

Status
Not open for further replies.

rpk2006

Technical User
Apr 24, 2002
225
0
0
IN
I have the following arrary declared and the values it receives:

Code:
Option Explicit
Dim NV

Private Sub cmdNext_Click()
        Dim VehicleArray 	
    ReDim VehicleArray(NV, 10)
        For i = 0 To NV
            Call ValidateFields
            
          VehicleArray(i, 0) = chkC.value
          VehicleArray(i, 1) = chkB.value
          VehicleArray(i, 2) = txtPH.Text
          VehicleArray(i, 3) = txtVRN.Text
          VehicleArray(i, 4) = Val(txtNoV.Text)
          VehicleArray(i, 5) = txtVID.Text
          VehicleArray(i, 6) = Val(txtV12I.Text)
          VehicleArray(i, 7) = Val(txtV12S.Text)
          VehicleArray(i, 8) = Val(txtV12O.Text)
          VehicleArray(i, 9) = Val(txtC12I.Text)
         VehicleArray(i, 10) = Val(txtC12S.Text)
        Next	
End Sub

I have a Data Entry Form which will accept the above given 10 values for NV vehicles. The FORM
has a Command Button with caption NEXT. I want to know that after entering values and pressing
the NEXT button, the first array gets filled, but will the program wait on the field to enter the
values or the FOR...NEXT loop will finish putting the same values from the Text Boxes.

Later if the code successfully accepts values for NV vehicles, I have to print them as well.
The above accepted values will be used to fill the bill, so I need to determine that after printing
first bill the FOR...NEXT loop should retrieve values for second bill and then print it.

The printing will be automated for NV bills.

Suggest any efficient approach.
 
Have you thought about using a user defined type?
 
on NEXT you'll have to incriment a variable (i.e. count)
and use it as index instead of the for...next loop
 
and as VBrit said it's better to use user defined type
unless you have all your textboxes indexed.
 
Kindly illustrate the user-defined type.
 
Something kind of like this:

Option Explicit
Dim NV
Dim i
Private Type udtVehicle
C As Integer
B As Integer
PH As String
VRN As String
NoV As Integer
VID As String
V12I As Integer
V12S As Integer
V12O As Integer
C12I As Integer
C12S As Integer
End Type
Dim VehicleArray() As udtVehicle

Private Sub cmdNext_Click()
NV = 0
ReDim VehicleArray(NV)
For i = 0 To NV
Call ValidateFields
VehicleArray(i).C = chkC.Value
VehicleArray(i).B = chkB.Value
VehicleArray(i).PH = txtPH.Text
VehicleArray(i).VRN = txtVRN.Text
VehicleArray(i).NoV = Val(txtNoV.Text)
VehicleArray(i).VID = txtVID.Text
VehicleArray(i).V12I = Val(txtV12I.Text)
VehicleArray(i).V12S = Val(txtV12S.Text)
VehicleArray(i).V12O = Val(txtV12O.Text)
VehicleArray(i).C12I = Val(txtC12I.Text)
VehicleArray(i).C12S = Val(txtC12S.Text)
Next
End Sub

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top