> ok try this....
> -------------------------------------------------------------
[quoted text clipped - 70 lines]
> --
> Rory
> OK so If I were making a dog class and I wanted it to have these
> properties:(these are user definable through textbox)
[quoted text clipped - 6 lines]
> Wakeup
> how would I put this into a class
Well your properties would likely be read and write capable. for example...
-------------------------------------------------------------
Private mBreed as String ' Note you could use an Enum here but I'm using
a string for simplicity
Public Property Breed as String
Get
return mBreed
End Get
Set(Value as String)
mBreed = Value
End Set
End Property
-------------------------------------------------------------
> So then if I want to put in a name for breed and a wieght and then I
> want to display that in a lable I would just put
> mylabel.text ="Your dog, a " & mydog.breed & " wieghs " & mydog.Weight
> & "pounds"
> Is this right or am I missing the point.
In order to say
-------------------------------------------------------------
mylabel.text ="Your dog, a " & mydog.breed & " wieghs " & mydog.Weight &
"pounds"
-------------------------------------------------------------
...which is correct syntax in vb.
You would need to have instantiated (created) 'mydog' and set the properties
appropriately...
-------------------------------------------------------------
Dim mydog as New Dog
mydog.breed = "SomeValue"
mydog.Weight = 45 ' 45 what I don't know :)
-------------------------------------------------------------
> public class mydog
> public property
> set Bark
> public property
> set sleep
> would it look something like that?
Not sure exactly what you're trying to do here, but 'call' is the (optional)
keyword to proceed a call to a sub (method with no return value)
The methods for 'Sleep' etc would be similar, in structure at least, to 'Walk'
and 'WagTail' inmy previous example.
Does this make things any clearer?
--
Ror
Ron - 13 Apr 2007 02:05 GMT
> > OK so If I were making a dog class and I wanted it to have these
> > properties:(these are user definable through textbox)
[quoted text clipped - 59 lines]
> --
> Rory
I'm still not understanding how to make the class and set the
properties.
Here are the buttons and the buttons coded for the mydog class that I
would like to make.
Private Sub btnSleep_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSleep.Click
mydog.sleep()
sleepmode()
End Sub
Private Sub btnWakeUp_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnWakeUp.Click
mydog.wakeup()
sleepmode()
End Sub
Private Sub sleepmode()
If mydog.awake Then
btnWakeUp.Enabled = False
btnSleep.Enabled = True
lbloutputs.Text = output & " Your new dog is awake"
Else
btnWakeUp.Enabled = True
btnSleep.Enabled = False
lbloutputs.Text = output & " Your new dog is asleep"
End If
End Sub
I am having no luck figuring out how to write a class for this. I
guess I am not understanding the concepts of the class.
Tom Leylan - 13 Apr 2007 03:19 GMT
Ron: I understand your desire to start in just writing stuff but I'm going
to make the suggestion that you start by reading a book on the "principles"
of OOP and not specifically on VB.Net. A language is only an implementation
of the concept, it is the concept you need to understand.
Then proceed to examples in VB.Net so you add "syntax" to your basic
understanding. Resist however the inclination to immediately start with a
UI as forms, buttons, events and such isn't OOP or VB.Net. If you need to
learn databinding simultanously with what constitutes a Cat class then by
all means jump right in but you will be confused as the OOP, the VB.Net and
the UI interactions all jumble together to form a mountain of confusion.
There are free books on OOP available on the Internet.
"Ron" <pts4560@yahoo.com> wrote...
>> > OK so If I were making a dog class and I wanted it to have these
>> > properties:(these are user definable through textbox)
[quoted text clipped - 94 lines]
> I am having no luck figuring out how to write a class for this. I
> guess I am not understanding the concepts of the class.