473,698 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to define a "Type"?

Kay
Hi all,

In vb6, I can define a custom type like this:

Private Type uClient
sName As String
sMonday As Double
sMondayHeadCnt As Integer
End Type

Wondering is it possible to do the same thing in .net?

Thanks~~

Kay
Jan 3 '06 #1
6 3586
Use a structure. Or better yet just define a class with properties.

Public Stucture uClient
Dim sName As String
Dim sMonday as Double
Dim sMondayHeadCnt AsInteger

End Structure

Public Class Client

Private mName As String
Private mMonday As Double
Private mMondayHeadCoun t As Integer

Public Sub New(name As String, monday As Double, mondayHeadCount as
Integer)
mName = name
mMonday = monday
mMondayHeadCoun t = mondayHeadCount

End Sub

Public Property Name() As String
. . .
End Property

Public Property Monday() As Double
. . .
End Property

Public Property MondayHeadCount () As Integer
. . .
End Property

End Class

"Kay" <kk@micxsoft.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi all,

In vb6, I can define a custom type like this:

Private Type uClient
sName As String
sMonday As Double
sMondayHeadCnt As Integer
End Type

Wondering is it possible to do the same thing in .net?

Thanks~~

Kay

Jan 3 '06 #2
Kay
Thanks a lot Ray ! ! ! !

Kay :D
"Ray Cassick (Home)" <rc************ @enterprocity.c om> wrote in message
news:O2******** *****@TK2MSFTNG P12.phx.gbl...
Use a structure. Or better yet just define a class with properties.

Public Stucture uClient
Dim sName As String
Dim sMonday as Double
Dim sMondayHeadCnt AsInteger

End Structure

Public Class Client

Private mName As String
Private mMonday As Double
Private mMondayHeadCoun t As Integer

Public Sub New(name As String, monday As Double, mondayHeadCount as
Integer)
mName = name
mMonday = monday
mMondayHeadCoun t = mondayHeadCount

End Sub

Public Property Name() As String
. . .
End Property

Public Property Monday() As Double
. . .
End Property

Public Property MondayHeadCount () As Integer
. . .
End Property

End Class

"Kay" <kk@micxsoft.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi all,

In vb6, I can define a custom type like this:

Private Type uClient
sName As String
sMonday As Double
sMondayHeadCnt As Integer
End Type

Wondering is it possible to do the same thing in .net?

Thanks~~

Kay


Jan 4 '06 #3
No problem.

Personally I think the class method is cleaner and more OOP so I use it
more. It is a bit more work but when it comes to eventually wanting to do
things like provide methods that act on your type (ie: ToString, Equals,
CopyTo, etc...) you are going to end up going the class route anyway.

That is not to say that you cant build a structure with methods and
properties, you can do that too, but then really what is the difference
between a structure and a class :)

Just go with a class, inherit from System.Object like all the other base
class types do and you are all set.
"Kay" <kk@micxsoft.co m> wrote in message
news:uO******** ******@TK2MSFTN GP14.phx.gbl...
Thanks a lot Ray ! ! ! !

Kay :D
"Ray Cassick (Home)" <rc************ @enterprocity.c om> wrote in message
news:O2******** *****@TK2MSFTNG P12.phx.gbl...
Use a structure. Or better yet just define a class with properties.

Public Stucture uClient
Dim sName As String
Dim sMonday as Double
Dim sMondayHeadCnt AsInteger

End Structure

Public Class Client

Private mName As String
Private mMonday As Double
Private mMondayHeadCoun t As Integer

Public Sub New(name As String, monday As Double, mondayHeadCount as
Integer)
mName = name
mMonday = monday
mMondayHeadCoun t = mondayHeadCount

End Sub

Public Property Name() As String
. . .
End Property

Public Property Monday() As Double
. . .
End Property

Public Property MondayHeadCount () As Integer
. . .
End Property

End Class

"Kay" <kk@micxsoft.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi all,

In vb6, I can define a custom type like this:

Private Type uClient
sName As String
sMonday As Double
sMondayHeadCnt As Integer
End Type

Wondering is it possible to do the same thing in .net?

Thanks~~

Kay



Jan 4 '06 #4
Kay
Hi Ray and all....

Just another question about the structure...

If the structure's variable has array like this:

Public Stucture uClient
Dim sName() As String
Dim sMonday() as Double
Dim sMondayHeadCnt( ) AsInteger
End Structure

And when I try to access the data :
Msgbox (myClient.sName (i))
I got an "Object reference not set to an instance of an object"...

Is it because there're no value assigned in the array? If that's the case
how do I check whether the array is populated or not?

Thanks~~

Kay
"Ray Cassick (Home)" <rc************ @enterprocity.c om> wrote in message
news:O2******** *****@TK2MSFTNG P12.phx.gbl...
Use a structure. Or better yet just define a class with properties.

Public Stucture uClient
Dim sName As String
Dim sMonday as Double
Dim sMondayHeadCnt AsInteger

End Structure

Public Class Client

Private mName As String
Private mMonday As Double
Private mMondayHeadCoun t As Integer

Public Sub New(name As String, monday As Double, mondayHeadCount as
Integer)
mName = name
mMonday = monday
mMondayHeadCoun t = mondayHeadCount

End Sub

Public Property Name() As String
. . .
End Property

Public Property Monday() As Double
. . .
End Property

Public Property MondayHeadCount () As Integer
. . .
End Property

End Class

"Kay" <kk@micxsoft.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi all,

In vb6, I can define a custom type like this:

Private Type uClient
sName As String
sMonday As Double
sMondayHeadCnt As Integer
End Type

Wondering is it possible to do the same thing in .net?

Thanks~~

Kay


Jan 4 '06 #5
Kay
Hi Ray,

Yeah I agree (espeically it's "a bit more work")... ha ha~

I just post another question in this thread(hope u or other can help me
out), one of the reason I stick with structure is I need an array of each
variables(i.e. Monday - Sunday and with each day's Headcount, the sName is
actually a Campaign name if it confuse you), and the structure is just a
temp "variable" used to populate a listview, but as you said, I may end up
with OOP anyway~

Kay
"Ray Cassick (Home)" <rc************ @enterprocity.c om> wrote in message
news:uF******** *****@TK2MSFTNG P09.phx.gbl...
No problem.

Personally I think the class method is cleaner and more OOP so I use it
more. It is a bit more work but when it comes to eventually wanting to do
things like provide methods that act on your type (ie: ToString, Equals,
CopyTo, etc...) you are going to end up going the class route anyway.

That is not to say that you cant build a structure with methods and
properties, you can do that too, but then really what is the difference
between a structure and a class :)

Just go with a class, inherit from System.Object like all the other base
class types do and you are all set.
"Kay" <kk@micxsoft.co m> wrote in message
news:uO******** ******@TK2MSFTN GP14.phx.gbl...
Thanks a lot Ray ! ! ! !

Kay :D
"Ray Cassick (Home)" <rc************ @enterprocity.c om> wrote in message
news:O2******** *****@TK2MSFTNG P12.phx.gbl...
Use a structure. Or better yet just define a class with properties.

Public Stucture uClient
Dim sName As String
Dim sMonday as Double
Dim sMondayHeadCnt AsInteger

End Structure

Public Class Client

Private mName As String
Private mMonday As Double
Private mMondayHeadCoun t As Integer

Public Sub New(name As String, monday As Double, mondayHeadCount as
Integer)
mName = name
mMonday = monday
mMondayHeadCoun t = mondayHeadCount

End Sub

Public Property Name() As String
. . .
End Property

Public Property Monday() As Double
. . .
End Property

Public Property MondayHeadCount () As Integer
. . .
End Property

End Class

"Kay" <kk@micxsoft.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi all,

In vb6, I can define a custom type like this:

Private Type uClient
sName As String
sMonday As Double
sMondayHeadCnt As Integer
End Type

Wondering is it possible to do the same thing in .net?

Thanks~~

Kay



Jan 4 '06 #6
You can check the length of the array (ie: myClient.sName. Length) to see if
it is grater than 0.

....but I really think you need to consider refactoring this into a class and
access your data through properties.
"Kay" <kk@micxsoft.co m> wrote in message
news:%2******** **********@TK2M SFTNGP12.phx.gb l...
Hi Ray and all....

Just another question about the structure...

If the structure's variable has array like this:

Public Stucture uClient
Dim sName() As String
Dim sMonday() as Double
Dim sMondayHeadCnt( ) AsInteger
End Structure

And when I try to access the data :
Msgbox (myClient.sName (i))
I got an "Object reference not set to an instance of an object"...

Is it because there're no value assigned in the array? If that's the case
how do I check whether the array is populated or not?

Thanks~~

Kay
"Ray Cassick (Home)" <rc************ @enterprocity.c om> wrote in message
news:O2******** *****@TK2MSFTNG P12.phx.gbl...
Use a structure. Or better yet just define a class with properties.

Public Stucture uClient
Dim sName As String
Dim sMonday as Double
Dim sMondayHeadCnt AsInteger

End Structure

Public Class Client

Private mName As String
Private mMonday As Double
Private mMondayHeadCoun t As Integer

Public Sub New(name As String, monday As Double, mondayHeadCount as
Integer)
mName = name
mMonday = monday
mMondayHeadCoun t = mondayHeadCount

End Sub

Public Property Name() As String
. . .
End Property

Public Property Monday() As Double
. . .
End Property

Public Property MondayHeadCount () As Integer
. . .
End Property

End Class

"Kay" <kk@micxsoft.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi all,

In vb6, I can define a custom type like this:

Private Type uClient
sName As String
sMonday As Double
sMondayHeadCnt As Integer
End Type

Wondering is it possible to do the same thing in .net?

Thanks~~

Kay



Jan 5 '06 #7

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

Similar topics

9
13403
by: David D. | last post by:
Does the file extension matter when including a JavaScript file in an HTML page? Normally, one would include a JavaScript file in an HTML page using <script src="foo.JS" type="text/javascript"> However, I have found that I can use an alternate file extension, such as <script src="foo.HTML" type="text/javascript"> It works fine with my IE 6 and Mozilla. Will it work with other browsers?
3
4788
by: Maersa | last post by:
Hi All, Was anybody able to serialize the "Type" class properly using XmlSerializer().... Want to serialize and deserialze the Type in a string form, but can this be done ? myobj.Type = typeof(System.String) as <type>System.String</type> thanks a ton.
1
3292
by: Mark Sandfox | last post by:
Is there a way to restrict the user to only selecting and sending either a ..gif or .jpg. Everything I have read says this option can not be done by design (security reasons). I find that irronic as this is the reason (security) that I want to restrict their selection. Any help on this one will be greatly appreciated. The page is using ASP.NET.
1
9449
by: A.M-SG | last post by:
Hi, I am trying to simplify my app.config file. Can I have a section handler in a separated file? I am looking for something like this: <section name=".." type=".." file="..."> but it gives me error! Am I missing a specific syntax?
5
3920
by: cowgurl art | last post by:
Hey there. I will not pretend to know more than I do...I'm just getting my feet wet with Dreamweaver and MySql databases. What I'm trying to do is create a form that will allow members to submit an audio file (mp3 or .wav) from a website. The form will insert the record into the database IF I can get it configured correctly. Here's the problem- I don't know what type to list the field as in order to get it to accept a file upload. Is this...
3
2927
blazedaces
by: blazedaces | last post by:
I've taken a look at the class and you only seem to be able to set the file name, but not it's save type. Why is this? Here's some code if you want it, but it doesn't seem to have a method for choosing the type of file to save: public void save(double x, double y) { FileDialog fd = new FileDialog(new Frame(), "Choose a text file to save to...", FileDialog.SAVE); fd.setFile("*.txt");
3
12551
by: eros | last post by:
ALTER TABLE public.postcodes ALTER COLUMN machi TYPE varchar(100); Error: ERROR: syntax error at or near "TYPE"; Error while executing the query (State:42601, Native Code: 7) I am using WinSQL, Windows XP SP2 Japanese Version, PostgreSQL 8.x. I want to alter my machi field from varchar(30) to varchar(100) TYPE. This is my CREATE TABLE script:
1
12324
by: mato81 | last post by:
Hi all! I am a newbie to WSDL. I have a questions which has been driving me crazy... If I would have a WSDL with a types element somewhat like below, what is the point of the third last row "<s:element name="string" nillable="true" type="s:string"/>". Why is it there and what is it for? ... <wsdl:types> <s:schema elementFormDefault="qualified" targetNamespace="http://www.home.NET"> <s:element name="GetWeather">
13
1928
vikas251074
by: vikas251074 | last post by:
When change the <script language="javascript"> to <script type="text/javascript">, javascript function now works no more. Previously it was working. Javascript function is given below - function log1() { window.location="log1.asp" } function page1() { window.location="page1.asp" }
0
8676
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, 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...
0
9164
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, 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...
0
9029
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 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...
1
8898
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7734
agi2029
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...
0
5860
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
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
3
2006
bsmnconsultancy
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...

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.