473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Initialize an array of structure in a client app

Hi,
I have two structures. One containing(EmailMessage) an array of the
other(AttFile). When I try to work with in my VB.NET app iIalways receive an
error off this type Object reference not set to an instance of an object.
This is my code. ANy help please!!!!

Public Structure EmailMessage
Public FichsAttaches() As FichierAttaches
Public DestinataireCourriel As String
Public ExpediteurCourriel As String
Public CCDestinataireCourriel As String
Public SujetCourriel As String
Public MsgCourriel As String
Public ImportanceCourriel As ImportanceCourl
Public FormatCourriel As FormatMessage
Public EncodageCourriel As TypeEncodage

End Structure
Public Structure AttFile
Public NomFichierAttache As String
Public FichierAttache() As Byte
End Structure

Dim objEmail As New localhost.EmailMessage
Dim objFichAtch As New localhost.AttFile
Dim strNomFich As String = "README.txt"

Try

objEmail.ExpediteurCourriel = "blabla"
objEmail.DestinataireCourriel = "blabla"
objEmail.CCDestinataireCourriel = ""
objEmail.SujetCourriel = "Test"
objEmail.MsgCourriel = "Goodddddddddd"
objEmail.FormatCourriel =
CType(System.Enum.Parse(GetType(localhost.FormatMe ssage),
cboFormat.SelectedItem.ToString()), localhost.FormatMessage)
objEmail.EncodageCourriel =
CType(System.Enum.Parse(GetType(localhost.TypeEnco dage),
Me.cboEncodage.SelectedItem.ToString()), localhost.TypeEncodage)
objEmail.ImportanceCourriel =
CType(System.Enum.Parse(GetType(localhost.Importan ceCourl),
cboImpor.SelectedItem.ToString()), localhost.ImportanceCourl)
objFichAtch.FichierAttache = AjouterAtch(strNomFich, "C:\")
objFichAtch.NomFichierAttache = strNomFich
objEmail.FichiersAttaches(0) = objFichAtch ---> Here where the
error occur
************************************************** ****************

Catch ex As soapException
MessageBox.Show(ex.Message)
End Try
Nov 21 '05 #1
1 1892
Ok, I find it
"Ghislain Tanguay" <gh****************************@hotmail.com> a écrit dans
le message de news:u3**************@TK2MSFTNGP10.phx.gbl...
Hi,
I have two structures. One containing(EmailMessage) an array of the
other(AttFile). When I try to work with in my VB.NET app iIalways receive an error off this type Object reference not set to an instance of an object.
This is my code. ANy help please!!!!

Public Structure EmailMessage
Public FichsAttaches() As FichierAttaches
Public DestinataireCourriel As String
Public ExpediteurCourriel As String
Public CCDestinataireCourriel As String
Public SujetCourriel As String
Public MsgCourriel As String
Public ImportanceCourriel As ImportanceCourl
Public FormatCourriel As FormatMessage
Public EncodageCourriel As TypeEncodage

End Structure
Public Structure AttFile
Public NomFichierAttache As String
Public FichierAttache() As Byte
End Structure

Dim objEmail As New localhost.EmailMessage
Dim objFichAtch As New localhost.AttFile
Dim strNomFich As String = "README.txt"

Try

objEmail.ExpediteurCourriel = "blabla"
objEmail.DestinataireCourriel = "blabla"
objEmail.CCDestinataireCourriel = ""
objEmail.SujetCourriel = "Test"
objEmail.MsgCourriel = "Goodddddddddd"
objEmail.FormatCourriel =
CType(System.Enum.Parse(GetType(localhost.FormatMe ssage),
cboFormat.SelectedItem.ToString()), localhost.FormatMessage)
objEmail.EncodageCourriel =
CType(System.Enum.Parse(GetType(localhost.TypeEnco dage),
Me.cboEncodage.SelectedItem.ToString()), localhost.TypeEncodage)
objEmail.ImportanceCourriel =
CType(System.Enum.Parse(GetType(localhost.Importan ceCourl),
cboImpor.SelectedItem.ToString()), localhost.ImportanceCourl)
objFichAtch.FichierAttache = AjouterAtch(strNomFich, "C:\")
objFichAtch.NomFichierAttache = strNomFich
objEmail.FichiersAttaches(0) = objFichAtch ---> Here where the error occur
************************************************** ****************

Catch ex As soapException
MessageBox.Show(ex.Message)
End Try

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: steveneng | last post by:
C++ Primer Plus Programming Exercises 4th Ed - Prate Help I'm trying to refresh myself and I'm stuck on this problem (not homework/school related but for personal advancement). 6: Do...
4
by: Mark Hannon | last post by:
I am trying to initialize an array only once so it can be seen & used by any functions that need it. As I understand it, if a variable is declared by itself outside of any functions, its scope is...
1
by: Michael Hill | last post by:
I am creating a page where I want to dynamically fillin the contents of a table based on user selections. The page is created from a cgi. I have a number of rows, say 150 that I want to hide...
7
by: Andi.Martin | last post by:
Hi, how is it possible, to only initialize parts of a structure. Example: typedef struct{ int a, b; ... (huge lot of members); double x,y;
6
by: Ramprasad A Padmanabhan | last post by:
I have a simple structure defined like this struct userid { char uid; int insize; int outsize; }; typedef struct userid user;
6
by: Carl | last post by:
Hi, I want to pass an array of object of different type to a function and use it in the function. I am not able to have it working. Function that create the array... public virtual DataSet...
5
by: Cybertof | last post by:
Hello, Is it possible to convert a VB6 Array of Struct to a C# Array Of Struct ? The test context is a C# application calling a VB6 ActiveX DLL Function using UDT (User Defined Type) and...
5
by: Bill Nicholson | last post by:
I declared a UDT... Structure TeamRankingsStruc Public intRankings() As Int16 ' The dimension must be omitted in the context of a data type definition Public strName As String End...
3
by: vduber6er | last post by:
Lets say I have this structure: typedef struct numbers { double first = 0.0; double second = 0.0; double third = 0.0; } MYVALUES; and I initialize an array of MYVALUES like the following
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.