|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Public StructureHi 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 Will this do :
MeterAccountName=nothing zulan***@gmail.com wrote: Show quoteHide quote > 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 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 <zulan***@gmail.com> wrote in message Show quoteHide quote news:1153138185.209492.140580@b28g2000cwb.googlegroups.com... > Will this do : > MeterAccountName=nothing > > zulan***@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 > 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 Show quoteHide quote "Samuel Shulman" <samuel.shul***@ntlworld.com> wrote in message news:udjp82ZqGHA.4032@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 > > > > > <zulan***@gmail.com> wrote in message > news:1153138185.209492.140580@b28g2000cwb.googlegroups.com... >> Will this do : >> MeterAccountName=nothing >> >> zulan***@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 >> > > "Claes Bergefall" wrote: In fact, this method works in C#, too, but only in the initial definition of > 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") the variable. You do not have to explicitely assign null to it, though: MyStruct msInst; msInst.myField = value; -- Best regards, Stanimir Stoyanov admin@nospam.stoyanoff.info Perhaps you can create a method to do that or assign a new variable
ob = new MeterAccountName <zulan***@gmail.com> wrote in message Show quoteHide quote news:1153136263.423559.42950@s13g2000cwa.googlegroups.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 > 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" <samuel.shul***@ntlworld.com> a écrit dans le message de news: efU93zZqGHA.3***@TK2MSFTNGP04.phx.gbl...Show quoteHide quote > Perhaps you can create a method to do that or assign a new variable > > ob = new MeterAccountName > > > > <zulan***@gmail.com> wrote in message > news:1153136263.423559.42950@s13g2000cwa.googlegroups.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 >> > >
Bug or Feature? CancelButton vs Escape Key
overides/loads usage Problems using Me.Scale in Framework 2.0 ListView and ImageList/ImageKey An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll Sendmessage problem help! enforce event calling on inherited classes Holding down a key HELP: Problem Hosting the "Simplest" of VB.NET Apps detect if running on a terminal server |
|||||||||||||||||||||||