I have a 'variable not declared' error occurring when in fact the var is
declared --its just nested in a If Then statement. Like so:
If bPortrait Then
'then its in portrait mode
' Make a bitmap for the result.
Dim bm_dest As New Bitmap(CInt(bm_source.Height *
scale_factor), CInt(bm_source.Width * scale_factor))
Else
'then it's in landscape mode
' Make a bitmap for the result.
Dim bm_dest As New Bitmap(CInt(bm_source.Width *
scale_factor), CInt(bm_source.Height * scale_factor))
End If
Why do I get this error when either way the If Then clause falls the var is
declared and will execute? I understand that I can set the If Then clause
for the height & width values and then declare the var outside of that. But
why doesn't the above --which is functionally equivalent-- work?
JW 4 1233
JW,
Where do you get the error?
Kerry Moorman
"Jerry West" wrote:
I have a 'variable not declared' error occurring when in fact the var is
declared --its just nested in a If Then statement. Like so:
If bPortrait Then
'then its in portrait mode
' Make a bitmap for the result.
Dim bm_dest As New Bitmap(CInt(bm_source.Height *
scale_factor), CInt(bm_source.Width * scale_factor))
Else
'then it's in landscape mode
' Make a bitmap for the result.
Dim bm_dest As New Bitmap(CInt(bm_source.Width *
scale_factor), CInt(bm_source.Height * scale_factor))
End If
Why do I get this error when either way the If Then clause falls the var is
declared and will execute? I understand that I can set the If Then clause
for the height & width values and then declare the var outside of that. But
why doesn't the above --which is functionally equivalent-- work?
JW
You mean when do I encounter the error? If so, the code window underlines
every instance of bm_dest; flagging it as an error. As well, if I try to run
the code I am not allowed to. Is that what you mean?
JW
"Kerry Moorman" <Ke**********@discussions.microsoft.comwrote in message
news:57**********************************@microsof t.com...
JW,
Where do you get the error?
Kerry Moorman
"Jerry West" wrote:
>I have a 'variable not declared' error occurring when in fact the var is declared --its just nested in a If Then statement. Like so:
If bPortrait Then
'then its in portrait mode
' Make a bitmap for the result. Dim bm_dest As New Bitmap(CInt(bm_source.Height * scale_factor), CInt(bm_source.Width * scale_factor))
Else
'then it's in landscape mode
' Make a bitmap for the result. Dim bm_dest As New Bitmap(CInt(bm_source.Width * scale_factor), CInt(bm_source.Height * scale_factor))
End If
Why do I get this error when either way the If Then clause falls the var is declared and will execute? I understand that I can set the If Then clause for the height & width values and then declare the var outside of that. But why doesn't the above --which is functionally equivalent-- work?
JW
JW,
What I meant was are you trying to use the variable outside the If - Then -
Else statement?
If so, then that is your problem. The scope of the variable is only within
the If - Then - Else statement. You need to dimension bm_dest at the top of
the procedure:
Dim bm_dest As BitMap
and then set it to a new instance inside the If statement.
Kerry Moorman
"Jerry West" wrote:
You mean when do I encounter the error? If so, the code window underlines
every instance of bm_dest; flagging it as an error. As well, if I try to run
the code I am not allowed to. Is that what you mean?
JW
"Kerry Moorman" <Ke**********@discussions.microsoft.comwrote in message
news:57**********************************@microsof t.com...
JW,
Where do you get the error?
Kerry Moorman
"Jerry West" wrote:
I have a 'variable not declared' error occurring when in fact the var is
declared --its just nested in a If Then statement. Like so:
If bPortrait Then
'then its in portrait mode
' Make a bitmap for the result.
Dim bm_dest As New Bitmap(CInt(bm_source.Height *
scale_factor), CInt(bm_source.Width * scale_factor))
Else
'then it's in landscape mode
' Make a bitmap for the result.
Dim bm_dest As New Bitmap(CInt(bm_source.Width *
scale_factor), CInt(bm_source.Height * scale_factor))
End If
Why do I get this error when either way the If Then clause falls the var
is
declared and will execute? I understand that I can set the If Then clause
for the height & width values and then declare the var outside of that.
But
why doesn't the above --which is functionally equivalent-- work?
JW
Ah, got it. I didn't realize it's scope was relegated to only the If Then
statement. Thanks!
JW
"Kerry Moorman" <Ke**********@discussions.microsoft.comwrote in message
news:F7**********************************@microsof t.com...
JW,
What I meant was are you trying to use the variable outside the If -
Then -
Else statement?
If so, then that is your problem. The scope of the variable is only within
the If - Then - Else statement. You need to dimension bm_dest at the top
of
the procedure:
Dim bm_dest As BitMap
and then set it to a new instance inside the If statement.
Kerry Moorman
"Jerry West" wrote:
>You mean when do I encounter the error? If so, the code window underlines every instance of bm_dest; flagging it as an error. As well, if I try to run the code I am not allowed to. Is that what you mean?
JW
"Kerry Moorman" <Ke**********@discussions.microsoft.comwrote in message news:57**********************************@microso ft.com...
JW,
Where do you get the error?
Kerry Moorman
"Jerry West" wrote:
I have a 'variable not declared' error occurring when in fact the var is declared --its just nested in a If Then statement. Like so:
If bPortrait Then
'then its in portrait mode
' Make a bitmap for the result. Dim bm_dest As New Bitmap(CInt(bm_source.Height * scale_factor), CInt(bm_source.Width * scale_factor))
Else
'then it's in landscape mode
' Make a bitmap for the result. Dim bm_dest As New Bitmap(CInt(bm_source.Width * scale_factor), CInt(bm_source.Height * scale_factor))
End If
Why do I get this error when either way the If Then clause falls the var is declared and will execute? I understand that I can set the If Then clause for the height & width values and then declare the var outside of that. But why doesn't the above --which is functionally equivalent-- work?
JW
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeroen van vliet |
last post by:
Hello i made a form (register)with an ADOdatacontrol object named Userinfo
(from lesson 22 on vbtutor.net/lesson22.html i made all the butoons and
scripts etc, but when i load it and click on...
|
by: Lauren Quantrell |
last post by:
I get the following error:
"Object variable or Width block variable not set error"
trying to run this in my Access2000 .ADP database:
CurrentDb.Properties.Append...
|
by: JMCN |
last post by:
hello-
i received an runtime error message: You tried to call Update or
CancelUpdate or attempted to update a Field in a recordset without
first calling AddNew or Edit. (Error 3020). when i look...
|
by: kellyatdentrix |
last post by:
Suppose that I just want to count the elements in a collection, so I do
this:
int i = 0;
foreach (MyElement el in MyCollection)
{
i++;
}
return i;
|
by: roman |
last post by:
Hi,
I have a form which validates data before submitting, it catches the
error, but still submits and can't seem to figure out why. Can someone
look at my code and give me some ideas how to...
| |
by: archana |
last post by:
Hi all,
I am new to asp.net. I am trying to use server.transfer and
respnse.redirect.
When i nagivate to page using server.transfer on navigated page if i
click on refresh i am getting...
|
by: moinmaraicar |
last post by:
Dear Sir,
i have used the following code to verify password. i am getting "Object variable or With block variable not set error" whie opening the next form after giving correct password. please...
|
by: Al G |
last post by:
Hi,
I'm converting a bit of POP3 VB6 code to VB2005, and have run into this
error with the following code.
Can someone help me find out what I'm missing/doing wrong?
'holds the attachments...
|
by: Newbie2VB |
last post by:
When I run my code, I get this "object variable or with block variable not set" error message.
Public Function fGetHeaderList() As String
Dim strList(5) As CheckBox
Dim i As Integer
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |