473,396 Members | 1,756 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,396 software developers and data experts.

Public Structure

Hi i have a Public Structure:

Public Structure MeterAccountName
Dim Meter As String
Dim Account_No As String
Dim xName As String
End Structure

is their a way to clear a structure without having to do the
fallowing:

MeterAccountName.Meter =""
MeterAccountName.Account =""
MeterAccountName.xName =""
Thank you

Jul 17 '06 #1
6 7034
Will this do :
MeterAccountName=nothing

zu******@gmail.com wrote:
Hi i have a Public Structure:

Public Structure MeterAccountName
Dim Meter As String
Dim Account_No As String
Dim xName As String
End Structure

is their a way to clear a structure without having to do the
fallowing:

MeterAccountName.Meter =""
MeterAccountName.Account =""
MeterAccountName.xName =""
Thank you
Jul 17 '06 #2
Perhaps you can create a method to do that or assign a new variable

ob = new MeterAccountName

<zu******@gmail.comwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...
Hi i have a Public Structure:

Public Structure MeterAccountName
Dim Meter As String
Dim Account_No As String
Dim xName As String
End Structure

is their a way to clear a structure without having to do the
fallowing:

MeterAccountName.Meter =""
MeterAccountName.Account =""
MeterAccountName.xName =""
Thank you

Jul 17 '06 #3
no, that will mean that the object doesn't point to any area in the memory
an you will not be able to use this object until you assign it a New
MeterAccountName

view my other posting


<zu******@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Will this do :
MeterAccountName=nothing

zu******@gmail.com wrote:
>Hi i have a Public Structure:

Public Structure MeterAccountName
Dim Meter As String
Dim Account_No As String
Dim xName As String
End Structure

is their a way to clear a structure without having to do the
fallowing:

MeterAccountName.Meter =""
MeterAccountName.Account =""
MeterAccountName.xName =""
Thank you

Jul 17 '06 #4
Actually both are working in VB 2005, but I'm not a big fan of using Nothing
as this is really not the same semantic than for objects. I prefer New but
I'm not yet totally convinced as this is not really something "new".

The third option which I tried would be to create a shared readonly "Empty"
property that returns an empty structure. This way you would just write :

MyStruct=MeterAccountName.Empty

(I thought also about a clear method but i could be easy to add a field and
forgot to reset it).

--
Patrice

"Samuel Shulman" <sa************@ntlworld.coma écrit dans le message de
news: ef**************@TK2MSFTNGP04.phx.gbl...
Perhaps you can create a method to do that or assign a new variable

ob = new MeterAccountName

<zu******@gmail.comwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...
>Hi i have a Public Structure:

Public Structure MeterAccountName
Dim Meter As String
Dim Account_No As String
Dim xName As String
End Structure

is their a way to clear a structure without having to do the
fallowing:

MeterAccountName.Meter =""
MeterAccountName.Account =""
MeterAccountName.xName =""
Thank you


Jul 17 '06 #5
Actually, setting it to Nothing will work in this case (much to my
surprise!) since it's a structure and not a class. You will only get away
with it in VB though. Trying the same thing in C# will give you a compiler
error ("Cannot convert null to '...' because it is a value type")

I would still recommend a separate method for it (like Clear or something).

/claes

"Samuel Shulman" <sa************@ntlworld.comwrote in message
news:ud**************@TK2MSFTNGP03.phx.gbl...
no, that will mean that the object doesn't point to any area in the memory
an you will not be able to use this object until you assign it a New
MeterAccountName

view my other posting


<zu******@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>Will this do :
MeterAccountName=nothing

zu******@gmail.com wrote:
>>Hi i have a Public Structure:

Public Structure MeterAccountName
Dim Meter As String
Dim Account_No As String
Dim xName As String
End Structure

is their a way to clear a structure without having to do the
fallowing:

MeterAccountName.Meter =""
MeterAccountName.Account =""
MeterAccountName.xName =""
Thank you


Jul 17 '06 #6
"Claes Bergefall" wrote:
surprise!) since it's a structure and not a class. You will only get away
with it in VB though. Trying the same thing in C# will give you a compiler
error ("Cannot convert null to '...' because it is a value type")
In fact, this method works in C#, too, but only in the initial definition of
the variable. You do not have to explicitely assign null to it, though:

MyStruct msInst;
msInst.myField = value;
--
Best regards,

Stanimir Stoyanov
ad***@nospam.stoyanoff.info
Jul 18 '06 #7

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

Similar topics

0
by: john bailo | last post by:
I am attempting to create a c# program to iterate through the messages in an Outlook/Exchange public folder and extract the headers. My apologies to the VB/VBA groups, but you seem to have more...
0
by: VB Programmer | last post by:
I have a public array (in a usercontrol) defined as: Public arrWebServers(0) As WebServers ' FYI: Public Structure WebServers Friend ServerName As String Friend MapIdAc As Short Friend...
5
by: cFleury | last post by:
Hi, I have a public structure which is initialized only at startup time but at least one of the elements of this structure is losing its value, this particular element is ONLY initialized at the...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
0
by: Ray Cassick \(Home\) | last post by:
Does anyone have any references to this anywhere? I can find tones of references using a single key but I would like to use public/private keys so that I don't have to worry about exposing my key...
8
by: Gregory | last post by:
I have a question about using STL containers in C++ class public interface. Lets say that I want to return some container from class method or accept class method parameter as some container. For...
11
by: prefersgolfing | last post by:
I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
8
by: blisspikle | last post by:
Can any Public class be inherited from? I installed some software on my pc and I can use it in my code, but I cannot seem to inherit from it. It was an executable that installed on my pc, I do not...
0
by: mvanroshum | last post by:
Hi, I have the following problem: The DataSource of a DataGrid can be set to an IList. The DataGrid nicely lists the objects in the IList, showing all the public properties of the objects as...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...
0
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...
0
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,...

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.