borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (help)Next Topic (VB data grid to Excel app) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Nesting If statements within a While Not loop
Poster Message
Nmacp
Level: Guest


icon 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
| Quote Reply
Coyote
Level: Guest

icon 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
| Quote Reply
AndreaVB Forum : VB General : Nesting If statements within a While Not loop
Previous Topic (help)Next Topic (VB data grid to Excel app) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder