Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Insert number with commas VB.NET 2010

rapsoyso09

Novice
Advanced Member
Messages
29
Reaction score
0
Points
26
Please help po sa mga master dyan. newbie pa kasi sa programming

Ito po problem ko
When i input 5 or more digit may bug po kasi.

example: if i input 12345 dapat output nya is 12,345
sa akin kasi ang automatic output is 51,234

NOTE: isang textbox lang gagamitin wala ng button tapos automatic po comma po sya pag > 999

this is my code:

Private Sub menu_input_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, txt_wof1.TextChanged

dim val1 as double

val1=val(txt_wof1.text) ''''txt_wof1.text name of my textbox

If val1 > 999 Then

txt_wof1.text = val1.ToString("#,###,###") '''na try ko na "N" or "N2"

end if

end sub
 
natry mo na "N0"?

na try ko na same result padin eh pag naka automatic.
pag hindi naka automatic ok naman ang codes.

ganito kasi pag type ko ng 12345
dapat 12,345. ang lalabas kasi 51,234 kasi yung cursor automatic lilipat sa leftside.


replace val with cdbl
val1=cdbl(txt_wof1.text)

error po sya . converting from string "" to type 'double' is not valid

anyway thanks sa feedback.
 
Last edited:
error po sya . converting from string "" to type 'double' is not valid

anyway thanks sa feedback.

ibig sabihin ng error na yan ay walang laman yung textbox mo.. lagyan mo ng checking kung may laman yung textbox mo.

If txt_wof1.Text = "" Then Exit Sub
Dim val1 As Double = CDbl(txt_wof1.Text)
txt_wof1.Text = val1.ToString("#,###,###")
txt_wof1.SelectionStart = Len(txt_wof1.Text)
 
Last edited:
ibig sabihin ng error na yan ay walang laman yung textbox mo.. Lagyan mo ng checking kung may laman yung textbox mo.

If txt_wof1.text = "" then exit sub
dim val1 as double = cdbl(txt_wof1.text)
txt_wof1.text = val1.tostring("#,###,###")
txt_wof1.selectionstart = len(txt_wof1.text)

wow working 100%
maraming maraming salamat po sa inyo..
 
gamit ka n lang ng Leave event. usually, yan ginagamit kompara sa Changed


Code:
 Private Sub TextBox1_Leave(sender As Object, e As EventArgs) Handles TextBox1.Leave
  If TextBox1.Text.Length > 0 Then 'Check if textbox has value
    If IsNumeric(TextBox1.Text) Then 'Check if textbox is numeric
     TextBox1.Text = Convert.ToDouble(TextBox1.Text).ToString("###,##0.00") 'convert to double then format the value
    End If
   End If
 End Sub
 
Last edited:
Back
Top Bottom