CaJack0

Hi, For my project IĄŻm going to be simulating a simple phone network. The user will be able to add phones to the network and such. My only question is: Is it possible to use one class for all the phones or will each phone need its own class IĄŻve already got a rough version working but its quite crude and consists of mainly click events and if statements. But from what IĄŻve discovered doing that IĄŻd now like to create it in a more structured fashion, creating a class for the exchange and phones. Any advice would be great, Thanks.



Re: Visual Basic Language Help with classes

Vano

Hello. Of course you can use one class for all the phones. Actually, this is one of the reasons why people invented classes.






Re: Visual Basic Language Help with classes

John Oliver (UK)MSP, VSIP

Hi,

This should get you started.

The number below is a real telephone number, just not my number.

Regards,

John

_______________________

Code Block

Option Strict On

Option Explicit On

Public Class Form1

'The next highlighted line should be one line in your code window.>>>>

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim aTelNumber As New Phone("+44", "(0)1642", "218121")

End Sub

End Class

Public Class Phone

Private countryCode, areaCode, number As String

Public Sub New(ByVal countryCode As String, ByVal areaCode As String, ByVal number As String)

Me.countryCode = countryCode

Me.areaCode = areaCode

Me.number = number

End Sub

Public Property country_code() As String

Get

Return Me.countryCode

End Get

Set(ByVal value As String)

Me.countryCode = value

End Set

End Property

Public Property area_code() As String

Get

Return Me.areaCode

End Get

Set(ByVal value As String)

Me.areaCode = value

End Set

End Property

Public Property tel_number() As String

Get

Return Me.number

End Get

Set(ByVal value As String)

Me.number = value

End Set

End Property

End Class