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 > Delphi, C etc > Compile Error: Block IF without END IF

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-12-04, 11:10
Doublel Doublel is offline
Registered User
 
Join Date: Aug 2004
Posts: 1
Compile Error: Block IF without END IF

I am fairly new to VB. My code keeps breaking and displaying this message:

Compile Error: Block IF without END IF

I think I have found that this is a bug in VB6 and I don't know how to fix my code so it will run.

Any help out there?
Reply With Quote
  #2 (permalink)  
Old 08-12-04, 14:03
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 10,554
Can you post the smallest sample of code that you can create that demonstrates the problem?

-PatP
Reply With Quote
  #3 (permalink)  
Old 08-12-04, 15:03
GDMI. GDMI. is offline
Registered User
 
Join Date: Apr 2004
Location: LA, CA
Posts: 125
Without looking at your code and as the error code indicates, you are missing an End IF. make sure that for every IF statement that includes more that one instruction you have an End IF.

eg:
'here you need End IF
If a = b then
instruction 1
intruction 2
end if

'this is fine too. you don't need end if here.
if a= b then instruction

Hope this helps. As Pat said, a sample of your code would help diagnose the problem.
Reply With Quote
  #4 (permalink)  
Old 09-22-04, 11:08
seraphiction seraphiction is offline
Registered User
 
Join Date: Sep 2004
Posts: 1
I have the exact opposite of this problem. My form says, "End If without Block If", and it has completely confused me because I do not have an extra End If.
Reply With Quote
  #5 (permalink)  
Old 02-19-05, 02:58
http://xof7.com http://xof7.com is offline
Registered User
 
Join Date: Feb 2005
Posts: 1
What you have to do is change ur if statements
for example
if text1.text = "lol" then
end
elseif text1.text = "it works" then
text1.text = "hoorah"
pretty simple to fix
Reply With Quote
  #6 (permalink)  
Old 02-21-05, 13:01
DavidCoutts DavidCoutts is offline
Registered User
 
Join Date: Jan 2004
Location: Aberdeen, Scotland
Posts: 1,067
another thing to quickly check is to make sure you dont have anything like this

if test then
with something
end if
end with

or any loops built such etc.

Change them to open and close sequentially i.e.

if test
with something
end with
end if
Reply With Quote
  #7 (permalink)  
Old 01-29-10, 16:21
CathyMe CathyMe is offline
Registered User
 
Join Date: Jan 2010
Location: Fiji
Posts: 4
Please help, I am really new to vb I got a compile error saying "Block If Without End If"
and everytime I try correcting it, it still gives me the same error and End Sub is highlighted...I am working with Option buttons which I am new to. Here's the code:

If optRateA.Value = True Then
intGross = intHours * optRateA
Else
If optRateB.Value = True Then
intGross = intHours * optRateB
Else: optRateC.Value = True
intGross = intHours * optRateC
End If

Please help me!
Reply With Quote
  #8 (permalink)  
Old 01-29-10, 16:44
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 10,554
Code:
If optRateA.Value = True Then
  intGross = intHours * optRateA
Else
  If optRateB.Value = True Then
    intGross = intHours * optRateB
  Else: optRateC.Value = True
    intGross = intHours * optRateC
  End If
Does this help? Code formatting can be a wonderful thing!

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #9 (permalink)  
Old 01-29-10, 16:47
Teddy Teddy is online now
Access Monkey.
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 5,351
Quote:
Originally Posted by Pat Phelan View Post
Code:
If optRateA.Value = True Then
  intGross = intHours * optRateA
Else
  If optRateB.Value = True Then
    intGross = intHours * optRateB
  Else: optRateC.Value = True
    intGross = intHours * optRateC
  End If
Does this help? Code formatting can be a wonderful thing!

-PatP
Indeed.


In visual studio, hold down Ctrl, then press "K", then WITHOUT LETTING GO OF CTRL, press "D".

Tends to cut down on time needed to hunt down issues with control structure formatting...


Also, look in to using a RadioButtonList. You could condense that to a single line by hitting up the SelectedValue/SelectedIndex properties:

intGross = intHours * yourRadioButtonList.SelectedValue
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***

Last edited by Teddy; 01-29-10 at 16:54.
Reply With Quote
  #10 (permalink)  
Old 02-02-10, 03:13
CathyMe CathyMe is offline
Registered User
 
Join Date: Jan 2010
Location: Fiji
Posts: 4
I am also doing a database for a company using vb6 and I'm just a beginner...I've already connected the database but then I have to make reports which I have already done but then I have to make a report which shows stocks that are less than 100...are there any codes to make reports show that without creating them?

help please!
Reply With Quote
  #11 (permalink)  
Old 02-02-10, 03:15
CathyMe CathyMe is offline
Registered User
 
Join Date: Jan 2010
Location: Fiji
Posts: 4
Thanx alot for the help!!!
Reply With Quote
  #12 (permalink)  
Old 02-02-10, 12:16
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 10,554
Do you have an answer for your reporting question?

If so, you're welcome. If not, I'll split this out as a separate message thread.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #13 (permalink)  
Old 02-09-10, 06:21
CathyMe CathyMe is offline
Registered User
 
Join Date: Jan 2010
Location: Fiji
Posts: 4
well actually I didnt use any code but I just created the data report..drag and drop the controls onto the report..but I just don't really know how to make a report show stocks that are less than 100.
well this is what I did, I went back to Access where the data came from and I made another column, naming it Stocks <100 and putting a checkbox next to every item and checking those items that have less than 100....or is there another way to do this????
Reply With Quote
  #14 (permalink)  
Old 02-09-10, 15:08
Teddy Teddy is online now
Access Monkey.
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 5,351
Depends on how your database is layed out.

How did you decide which stocks should get a checkbox?
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
Reply

Thread Tools
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On