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
Class attachmentBlock Parameter
Public cTypeAttach As String
Public cEncoding As String
Public cFileName As String
Public cAttachment As String
End Class
Public AttachBlock() = New attachmentBlock Parameter() {}
Sub Main()
AttachBlock(1). cTypeAttach = "Base64"
' The previous line generates an "Object variable or With block
variable not set." Error
Console.WriteLi ne(" Attach Block Type=" &
AttachBlock(1). cTypeAttach)
Console.Read()
End Sub
Thanks, Al G 5 3250
"Al G" <ag*******@nosp am.charter.nets chrieb
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
Class attachmentBlock Parameter
Public cTypeAttach As String
Public cEncoding As String
Public cFileName As String
Public cAttachment As String
End Class
Public AttachBlock() = New attachmentBlock Parameter() {}
Sub Main()
AttachBlock(1). cTypeAttach = "Base64"
' The previous line generates an "Object variable or With
block variable not set." Error
Console.WriteLi ne(" Attach Block Type=" &
AttachBlock(1). cTypeAttach)
Console.Read()
End Sub
I can not explain /this/ error because there is no With statement in your
code. If you got an IndexOutOfRange exception, I would recommend to create
an array that is not empty (Redim statement). Currently, you have an empty
array, but you are trying to access the first item in the array.
Armin
"Armin Zingler" <az*******@free net.dewrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
"Al G" <ag*******@nosp am.charter.nets chrieb
>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
snip for brevity, see below...
>> Console.Read ()
End Sub
I can not explain /this/ error because there is no With statement in your
code. If you got an IndexOutOfRange exception, I would recommend to create
an array that is not empty (Redim statement). Currently, you have an empty
array, but you are trying to access the first item in the array.
Armin
Thank you for taking the time, this is all a little new for me. I went
back,
and added a redim statement,
Module Module1
'holds the attachments
Class attachmentBlock Parameter
Public cTypeAttach As String
Public cEncoding As String
Public cFileName As String
Public cAttachment As String
End Class
Public AttachBlock() = New attachmentBlock Parameter() {}
Sub Main()
ReDim AttachBlock(20)
AttachBlock(1). cTypeAttach = "Base64"
' The previous line generates an "Object variable or With
' block variable not set." Error
Console.WriteLi ne(" Attach Block Type=" & AttachBlock(1). cTypeAttach)
Console.Read()
End Sub
End Module
The actual error is:
System.NullRefe renceException was unhandled
Message="Object variable or With block variable not set."
Source="Microso ft.VisualBasic"
Al G
"Al G" <ag*******@nosp am.charter.nets chrieb
>
"Armin Zingler" <az*******@free net.dewrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
"Al G" <ag*******@nosp am.charter.nets chrieb
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
>
snip for brevity, see below...
>
Console.Read()
>
End Sub
I can not explain /this/ error because there is no With statement
in your code. If you got an IndexOutOfRange exception, I would
recommend to create an array that is not empty (Redim statement).
Currently, you have an empty array, but you are trying to access
the first item in the array.
Armin
Thank you for taking the time, this is all a little new for me. I
went back,
and added a redim statement,
Module Module1
'holds the attachments
Class attachmentBlock Parameter
Public cTypeAttach As String
Public cEncoding As String
Public cFileName As String
Public cAttachment As String
End Class
Public AttachBlock() = New attachmentBlock Parameter() {}
Sub Main()
ReDim AttachBlock(20)
AttachBlock(1). cTypeAttach = "Base64"
' The previous line generates an "Object variable or With
' block variable not set." Error
Console.WriteLi ne(" Attach Block Type=" &
AttachBlock(1). cTypeAttach)
Console.Read()
End Sub
End Module
The actual error is:
System.NullRefe renceException was unhandled
Message="Object variable or With block variable not set."
Source="Microso ft.VisualBasic"
First, enable Option Strict and correct the syntax error. One valid syntax
is
Public AttachBlock As attachmentBlock Parameter()
This declares an array variable but it doesn't create an array, yet. The
array is created by the ReDim statement and the reference to the array is
stored in variable AttachBlock.
After using Redim, you can store 21 references (indexes 0 to 20) in the
array. Each item can point to an object of type attachmentBlock Parameter.
Currently, all 21 items don't contain references. They are "Nothing". You
must create an object and store the object reference in the array:
AttachBlock(1) = New attachmentBlock Parameter
After this you can store values in the object's properties:
AttachBlock(1). cTypeAttach = "Base64"
Note that only the item at index position 1 points to an object. All other
items in the array are still Nothing. You'd have to create objects in a loop
and store them - to be exact, only the object references - in the array.
(Also note that the length of an array can not be changed. If you want to
keep the number of items dynamic, you can also use an Arraylist instead. Or,
starting with VB 2005, there is also a generic List.)
Armin
Now the array is dimensioned to 20, which is good, but each array entry needs
to be initialized to a new object. The array initialization only opens the
array space.
Between the redim and using AttachBlock(1), insert this line:
AttachBlock (1) = New attachmentBlock Parameter
Also, it should be noted that AttachBlock(1) is actually the second array
element. AttachBlock(0) is the first.
"Al G" wrote:
>
"Armin Zingler" <az*******@free net.dewrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
"Al G" <ag*******@nosp am.charter.nets chrieb
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
snip for brevity, see below...
>
Console.Read()
End Sub
I can not explain /this/ error because there is no With statement in your
code. If you got an IndexOutOfRange exception, I would recommend to create
an array that is not empty (Redim statement). Currently, you have an empty
array, but you are trying to access the first item in the array.
Armin
Thank you for taking the time, this is all a little new for me. I went
back,
and added a redim statement,
Module Module1
'holds the attachments
Class attachmentBlock Parameter
Public cTypeAttach As String
Public cEncoding As String
Public cFileName As String
Public cAttachment As String
End Class
Public AttachBlock() = New attachmentBlock Parameter() {}
Sub Main()
ReDim AttachBlock(20)
AttachBlock(1). cTypeAttach = "Base64"
' The previous line generates an "Object variable or With
' block variable not set." Error
Console.WriteLi ne(" Attach Block Type=" & AttachBlock(1). cTypeAttach)
Console.Read()
End Sub
End Module
The actual error is:
System.NullRefe renceException was unhandled
Message="Object variable or With block variable not set."
Source="Microso ft.VisualBasic"
Al G
Thank You. This group has been wonderful.
Al G
"Armin Zingler" <az*******@free net.dewrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
"Al G" <ag*******@nosp am.charter.nets chrieb
>> "Armin Zingler" <az*******@free net.dewrote in message news:%2******* *********@TK2MS FTNGP05.phx.gbl ...
"Al G" <ag*******@nosp am.charter.nets chrieb
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
snip for brevity, see below...
>
Console.Read()
End Sub
I can not explain /this/ error because there is no With statement
in your code. If you got an IndexOutOfRange exception, I would
recommend to create an array that is not empty (Redim statement).
Currently, you have an empty array, but you are trying to access
the first item in the array.
Armin
Thank you for taking the time, this is all a little new for me. I went back, and added a redim statement,
Module Module1
'holds the attachments
Class attachmentBlock Parameter
Public cTypeAttach As String
Public cEncoding As String
Public cFileName As String
Public cAttachment As String
End Class
Public AttachBlock() = New attachmentBlock Parameter() {}
Sub Main()
ReDim AttachBlock(20)
AttachBlock(1) .cTypeAttach = "Base64"
' The previous line generates an "Object variable or With
' block variable not set." Error
Console.WriteL ine(" Attach Block Type=" & AttachBlock(1) .cTypeAttach)
Console.Read ()
End Sub
End Module The actual error is:
System.NullRef erenceException was unhandled Message="Object variable or With block variable not set." Source="Microso ft.VisualBasic"
First, enable Option Strict and correct the syntax error. One valid syntax
is
Public AttachBlock As attachmentBlock Parameter()
This declares an array variable but it doesn't create an array, yet. The
array is created by the ReDim statement and the reference to the array is
stored in variable AttachBlock.
After using Redim, you can store 21 references (indexes 0 to 20) in the
array. Each item can point to an object of type attachmentBlock Parameter.
Currently, all 21 items don't contain references. They are "Nothing". You
must create an object and store the object reference in the array:
AttachBlock(1) = New attachmentBlock Parameter
After this you can store values in the object's properties:
AttachBlock(1). cTypeAttach = "Base64"
Note that only the item at index position 1 points to an object. All other
items in the array are still Nothing. You'd have to create objects in a
loop
and store them - to be exact, only the object references - in the array.
(Also note that the length of an array can not be changed. If you want to
keep the number of items dynamic, you can also use an Arraylist instead.
Or,
starting with VB 2005, there is also a generic List.)
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Penn Markham |
last post by:
Hello all,
I am writing a script where I need to use the system() function to call
htpasswd. I can do this just fine on the command line...works great
(see attached file, test.php). When my webserver runs that part of the
script (see attached file, snippet.php), though, it doesn't go through.
I don't get an error message or anything...it just returns a "1"
(whereas it should return a "0") as far as I can tell. I have read the
PHP...
|
by: Danny J. Lesandrini |
last post by:
The following code works with a standard MDB to navigate
to a particluar record (with a DAO recordset, of course)
but it's giving me problems in an ADP I'm working on.
Dim rs As ADODB.Recordset
Set rs = Me.RecordsetClone
rs.Find "=" & lngContractID
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
I must site the Heisenberb Uncertainty Principal here, as it
|
by: Alfonso Morra |
last post by:
Hi,
I am at the end of my tether now - after spending several days trying to
figure how to do this. I have finally written a simple "proof of
concept" program to test serializing a structure containing pointers
into a "flattened" bit stream.
Here is my code (it dosen't work).
I would be grateful for any feedback that helps fix this. My intention
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen. It is
almost like it is trying to implement it's own COM interfaces...
below is the header, and a link to the dll+code:
Zip file with header, example, and DLL:...
|
by: VB Programmer |
last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally.
Example: In order to close/dispose a db connection you have to dim the
connection outside of the Try Catch Finally block. But, I prefer to dim them
"on the fly" only if needed (save as much resources as possible). A little
further... I may wish to create a sqlcommand and datareader object ONLY if
certain conditions are met. But, if I want to clean these up in the...
| |
by: Neo Geshel |
last post by:
I am trying to deal with an image in code-behind. I consistently get the
following error:
Server Error in '/' Application.
Object variable or With block variable not set.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object variable...
|
by: Richard Hollenbeck |
last post by:
I've marked the line in this subroutine where I've been getting this error.
It may be something stupid but I've been staring at this error trying to fix
it for over an hour. I'm pretty sure the table and field names and controls
are all named correctly, and the control referred to in the errant code is
open, and it has data in it.
Private Sub cmdAddIngredientToRecipe_Click()
' Get RecipeID for future action query
Dim recipeID As Long
|
by: Newbie19 |
last post by:
I'm trying to get a list of all subfolders in a folder on a share drive, but I keep on getting this error message:
Object variable or With block variable not set.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object variable or With block...
|
by: HillBilly |
last post by:
This is freaking me out. I'm using Membership and trying to determine if the
database is online. The GetConnectionString( ) method returns a connection
string as expected but not when used in the try block.
I have the Open() and Close() methods commented out while using the
Response.Redirect to test.
The code in the try block as shown will --never execute-- but the code in
the catch block --always executes-- whether the database is...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |