DOTNETCoder33
Member
- Joined
- Jun 18, 2010
- Messages
- 15
- Programming Experience
- Beginner
hey
i have a problem just now and am stuck on this subject
im doing a simple calculatro and was happy with the way i done things .. a ew member variables and a properties:
Private MVAR_Number1 As Decimal
Private MVAR_Number2 As Decimal
Private MVAR_Operator As Char
Public Property Number1() As Decimal
Get
Return MVAR_Number1
End Get
Set(ByVal value As Decimal)
MVAR_Number1 = value
End Set
End Property
Public Property Number2() As Decimal
Get
Return MVAR_Number2
End Get
Set(ByVal value As Decimal)
MVAR_Number2 = value
End Set
End Property
Public Property Operator_Selected() As Char
Get
Return MVAR_Operator
End Get
Set(ByVal value As Char)
MVAR_Operator = value
End Set
End Property
Public Function Result() As Decimal
If Operator_Selected = "+" Then
Return Number1 + Number2
ElseIf Operator_Selected = "-" Then
Return Number1 - Number2
ElseIf Operator_Selected = "*" Then
Return Number1 * Number2
ElseIf Operator_Selected = "/" Then
Return Number1 / Number2
End If
End Function
BUT now the book im reading into wants complicate things up a bit and i dont have a bloomin clue!!
it just seems all he has done is make things a heck of a lot more complex for something that is supposed to be so simple!
he is now saying "we can break up the expression" .. why would you want to do that tho if it already works?
he want to add this:
Dim Operators() As Char = ("+", "-", "*", "/")
Dim OpPos as Decimal
OpPos = Expr.IndexOfAny(Operators)
MvarNumber1 = CType (Expr.Substring (0,OpPos), Decimal
then goes similar for Number 2 ect
Just drives me mad how complex this is all getting for something so simple, fell like giving it all up !!
dont have a clue what the heck hes on about
not in a good mood today coz of this .. as you can tell ...
i have a problem just now and am stuck on this subject
im doing a simple calculatro and was happy with the way i done things .. a ew member variables and a properties:
Private MVAR_Number1 As Decimal
Private MVAR_Number2 As Decimal
Private MVAR_Operator As Char
Public Property Number1() As Decimal
Get
Return MVAR_Number1
End Get
Set(ByVal value As Decimal)
MVAR_Number1 = value
End Set
End Property
Public Property Number2() As Decimal
Get
Return MVAR_Number2
End Get
Set(ByVal value As Decimal)
MVAR_Number2 = value
End Set
End Property
Public Property Operator_Selected() As Char
Get
Return MVAR_Operator
End Get
Set(ByVal value As Char)
MVAR_Operator = value
End Set
End Property
Public Function Result() As Decimal
If Operator_Selected = "+" Then
Return Number1 + Number2
ElseIf Operator_Selected = "-" Then
Return Number1 - Number2
ElseIf Operator_Selected = "*" Then
Return Number1 * Number2
ElseIf Operator_Selected = "/" Then
Return Number1 / Number2
End If
End Function
BUT now the book im reading into wants complicate things up a bit and i dont have a bloomin clue!!
he is now saying "we can break up the expression" .. why would you want to do that tho if it already works?
he want to add this:
Dim Operators() As Char = ("+", "-", "*", "/")
Dim OpPos as Decimal
OpPos = Expr.IndexOfAny(Operators)
MvarNumber1 = CType (Expr.Substring (0,OpPos), Decimal
then goes similar for Number 2 ect
Just drives me mad how complex this is all getting for something so simple, fell like giving it all up !!
not in a good mood today coz of this .. as you can tell ...