TextBox - formattering input after event
Hey
I am used to VB6, but VB05 seems to puzzle me a bit. I am trying to a get a textbox to format its input after an event:
Event....
Dim Item1,Item2,etc... As Decimal
Dim Style1 As String = "0.#"
Dim Style2 As String = "0.###"
Select Case...
Case...
End Select...
'Now values has to be returned'
TextBox1.Text = TextBox1.Text.ToString(Style1) - However got it work using: VB6.Format(CDec(TextBox1.Text), "0.#") - used to be: Text1(0).Text = Format(Expression:=CCur(Text1(0).Text), Format:="0.#")
TextBox5.Text = MethanolAmount.ToString(Style2) "this works"
The problem is that I wanted TextBox1 to perform as TextBox5, so I tried attaching a Style1 with no luck. Got the following error - {"An object of type 'System.String' can not convert to type 'System.IFormatProvider'."} As I wrote before, I got it to work by using VB6.Format. However, it seems as a cheap solution. It most be possible to do it the "VB05 way".
I most admit that VB05 is powerful compared to VB6, but it seems as the easiest things as become difficult. I really miss the simple option of making an index of controls - ex. Public Sub Text1_GotFocus(Index As Integer) However, I figured that out using Wrox VB2005 Programmerâs reference â a marvellous book
|