If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > end if without block if

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-26-11, 03:54
nasse993 nasse993 is offline
Registered User
 
Join Date: May 2011
Posts: 1
Angry end if without block if

Okay i have some problem at Vba and i can't figure it out
the code goes like this, and when i run it it start crying about end if without block if
Quote:
Private Sub laske_Click()
If Val(yli) > 0 And Val(yli) < 2 Then Val (yli) * 1.5 Else Val (yli) * 2
End If
palkka = Val(tuntipalkka) * (Val(ma) + Val(ti) + Val(ke) + Val(tor) + Val(pe) + Val(la) + Val(su) + Val(yli))
End Sub
it's still in progress but i need to get trought this before i can continue.
and the program should calculate my salary

btw im starter so do not laugh

Last edited by nasse993; 05-26-11 at 05:17.
Reply With Quote
  #2 (permalink)  
Old 05-26-11, 16:46
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
from memory...

VB syntax has some basis in line returns etc....

Your code is technically incorrect as your else statement is not on a different line to your if statement. The following are valid versions of your code
Code:
Private Sub laske_Click()

    If Val(yli) > 0 And Val(yli) < 2 Then 
        Val (yli) * 1.5 
    Else 
        Val (yli) * 2
    End If

    palkka = Val(tuntipalkka) * (Val(ma) + Val(ti) + Val(ke) + Val(tor) + Val(pe) + Val(la) + Val(su) + Val(yli))

End Sub
or alternatively...

Code:
Private Sub laske_Click()

    If Val(yli) > 0 And Val(yli) < 2 Then Val (yli) * 1.5 Else Val (yli) * 2

    palkka = Val(tuntipalkka) * (Val(ma) + Val(ti) + Val(ke) + Val(tor) + Val(pe) + Val(la) + Val(su) + Val(yli))

End Sub
Pretty sure that is correct.
Reply With Quote
Reply

Tags
end if without block if

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On