 |
Nmacp Level: Guest

|
Nesting If statements within a While Not loop Archived to Disk
Can someone tell me why vb is complaining about there being a Wend without a while please?
Option Explicit
Sub Processbutton_click()
Dim payname, payID, PayClass As String
Dim payrate, pay, A, B, C As Currency
Dim hours As Single
A = 38
B = 40
C = 39.5
Open "payroll.txt" For Input As #1
Open "cheques.txt" For Output As #2
While Not EOF(1)
Input #1, payname, payID, hours, PayClass
Select Case PayClass
Case "A"
payrate = A
Case "B"
payrate = B
Case "C"
payrate = C
End Select
If PayClass = A Then
payrate = A
Else
If PayClass = B Then
payrate = B
Else
PayClass = C
End If
pay = hours * PayClass
Write #2, payname, payID, hours, pay
Wend
Close #1
Close #2
End Sub
|
|
27-07-2002 at 01:08 PM |
|
|  |
|
|
Coyote Level: Guest

|
Re: Nesting If statements within a While Not loop Archived to Disk
Thinking this will work. Added an additional end if.... Also... may be wrong, but think you want to open the second file for append since your reading thru the first file... so I changed that. Here is your code complete with changes... Hope this helps
' ********** Code Starts HERE *****
Option Explicit
Sub Processbutton_click()
Dim payname, payID, PayClass As String
Dim payrate, pay, A, B, C As Currency
Dim hours As Single
A = 38
B = 40
C = 39.5
Open App.Path & "payroll.txt" For Input As #1
Open App.Path & "cheques.txt" For Append As #2
While Not EOF(1)
Input #1, payname, payID, hours, PayClass
Select Case PayClass
Case "A"
payrate = A
Case "B"
payrate = B
Case "C"
payrate = C
End Select
If PayClass = A Then
payrate = A
Else
If PayClass = B Then
payrate = B
Else
PayClass = C
End If
End If
pay = hours * PayClass
Write #2, payname, payID, hours, pay
Wend
Close #1
Close #2
End Sub
|
|
27-07-2002 at 11:02 PM |
|
|  |
|
|
|
|
 |
 |