Guest deBruineBeren Posted January 4, 2006 Report Posted January 4, 2006 I would like to place the value of "FileLongGR" in to a textbox "txtLongGR". And fill the empty spaces in front of the value with zeros (00). In eMbedded Visual Basic I used this code: Dim FileLongGr Dim strLongGR As String strLongGR = String(3 - Len(FileLongGr), "0") & FileLongGr txtLongGr.Text = strLongGR Is there something like this for VB.NETCF ? Thanks in advance.
Guest Tech Posted January 4, 2006 Report Posted January 4, 2006 (edited) sorry, just to clarify you want to fill a textbox with 0's after a specific word has been set to the textbox text property? you can use the PadLeft or PadRight property to do this i believe for example: string tempString = "Some String"; this.textBox1.Text = tempString; this.textBox1.Text = this.textBox1.Text.PadRight(this.textBox1.MaxLength - tempString.Length, '0'); this is C# but should be no different than vb.net Edited January 4, 2006 by Tech
Guest deBruineBeren Posted January 4, 2006 Report Posted January 4, 2006 @ Tech, thanks for the hint. What I want to do is place a value in a textbox and fill the empty spaces in front of the value with zeros. This is the code i'm using now thanks to your hint: Dim LongGraden As String = MathClass.Graden(Longitude) txtLongGraden.Text = LongGraden.PadLeft(txtLongGraden.MaxLength, "0") The Matclass.Graden calculates the Longitude in degrees. The Maxlenght of textbox txtLongGraden = 2 So if the Longitude in degrees is for example 4 the textbox wil show 04. If the Longitude is 52 (here in the Netherlands) the textbox wil just show 52. Thanks again. Alex. ;)
Guest lspatricio Posted January 24, 2006 Report Posted January 24, 2006 @ Tech, thanks for the hint. What I want to do is place a value in a textbox and fill the empty spaces in front of the value with zeros. This is the code i'm using now thanks to your hint: Dim LongGraden As String = MathClass.Graden(Longitude) txtLongGraden.Text = LongGraden.PadLeft(txtLongGraden.MaxLength, "0") The Matclass.Graden calculates the Longitude in degrees. The Maxlenght of textbox txtLongGraden = 2 So if the Longitude in degrees is for example 4 the textbox wil show 04. If the Longitude is 52 (here in the Netherlands) the textbox wil just show 52. Thanks again. Alex. :D <{POST_SNAPBACK}> you may also want to use the Format string function. It's more flexible. ;)
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now