R
Robert
Thanks to anyone who has time to reply with some good advice or
indications. I posted this message to a visual basic group and was
kindly redirected here by an MVP, explaining that visual basic.net is
quite different to visual basic previous versions. Before anyone feels
tempted to flame or to scorn, I have RTFM, in fact various FM's and
nothing seems to help here. I have little experience of visual
basic.net at all, but I've been experimenting with this problem for
some time without making much headway.
A simple Roman numeral calculator.
Bob
indications. I posted this message to a visual basic group and was
kindly redirected here by an MVP, explaining that visual basic.net is
quite different to visual basic previous versions. Before anyone feels
tempted to flame or to scorn, I have RTFM, in fact various FM's and
nothing seems to help here. I have little experience of visual
basic.net at all, but I've been experimenting with this problem for
some time without making much headway.
A simple Roman numeral calculator.
More help appreciated if anyone has a few moments. Thanks.
Below is the code for textbox1 (without all the processing in each
case statement, of course, to make things clearer and omitting all the
declarations to keep it shorter).
At the moment ‘m' or another Roman letter typed in textbox1 produces
1000 in textbox2 or the corresponding value of that Roman letter.
‘mm' typed in textbox1 produces 0 in textbox2 but with a ‘backspace'
to ‘m' you get 2000 in textbox2. The logic of this is clear,
naturally.
However I would like ‘mm' in textbox1 to produce 2000, ‘mmc' to
produce 2100.
I thought the answer might lie in something like textbox1_keypress
with which I have been experimenting but cannot get this to work at
all.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles TextBox1.TextChanged
ROMAN = TextBox1.Text
ROMAN = UCase(ROMAN)
Select Case ROMAN
Case Is = "M"
NEWNUMBER = 1000
Case Is = "D"
NEWNUMBER = 500
Case Is = "C"
NEWNUMBER = 100
Case Is = "L"
NEWNUMBER = 50
Case Is = "X"
NEWNUMBER = 10
Case Is = "V"
NEWNUMBER = 5
Case Is = "I"
NEWNUMBER = 1
Case Else
NEWNUMBER = 0
End Select
SUM = SUM + NEWNUMBER
TextBox2.Text = SUM
End Sub
Thanks for any help or indications
Bob