What's up all. .net is here so i guess i will attempt to make the transition![]()
I haven't programmed in Visual Basic in awhile so im looking for code that is equivalent to Java. For instance i want to implement getters/setters in Visual Basic.
In Java i would just do somthing like.......
Now in Visual Basic .net i see that bolth are lumped in one property like the following.Code:public class Guage{ static private double temp; static private double dewpoint; public void setTemp(double temp){ this.temp = temp; } public double getTemp(){ return temp; } public void setDewpoint(double dewpoint){ this.dewpoint = dewpoint; } public double getDewpoint(){ return dewpoint; } public static void main(String[] args){ Guage g = new Guage(); System.out.println(" Temp is " + g.getTemp() + " Dewpoint is " + g.getDewpoint()); g.setTemp(56.7); g.setDewpoint(76.6); System.out.println(" Temp is " + g.getTemp() + " Dewpoint is " + g.getDewpoint()); } }
Is this the proper way to use code getters/setters in Visual Basic?Code:Dim strName as String Property Name() as String Get Name = strName End Get Set(byVal sName as String) strName = Value End Set End Property
And i thought that Visual Basic was true OOP? So i there a way to refrence the object in which the current method is being called? It seems stupid to define this method with a return type of String when say if the value is just being set then we don't want anything returned. That's the way it was in VB6. As in the following.
Code:Dim strName as String Property Get Name() as String Name = strName End Property Property Let Name(strNameIn as String) strName = strNameIn End Property


I haven't programmed in Visual Basic in awhile so im looking for code that is equivalent to Java. For instance i want to implement getters/setters in Visual Basic.
Reply With Quote
No i understand that the property only returns a value when the get part is called. But dosent this seem an akward way to program? It made more sense the way they were doing it before. Also you said "since a propety is constructed with a bolth a get and set keyword." It sounds like in order to construct a property a get and set must be supplied. Do i always need bolth? Thanks.
