+ Reply to Thread
Results 1 to 3 of 3

Number Formate in UserForm

  1. #1
    Forum Contributor
    Join Date
    04-09-2005
    Location
    Multan. Pakistan
    Posts
    131

    Number Formate in UserForm

    Hello Freinds,


    Can we show Number formate in UserForm i.e 100,000.00 instead of 100000


    Please tell me

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Syed Haider Ali,

    I am guessing you are talking about formatting the text in a textbox on a user form.

    Example of Formatting TextBox Text:
    'You can use the name of your textbox for TextBox1
    With TextBox1
    .Value = Format(.Value, "###,##0.00")
    End With



    If you want to automatically format the text after the user has entered it into the textbox, place the above code into the TextBox's AfterUpdate event.

    Automatically Format Entry:
    'You can use the name of your textbox for TextBox1
    Private Sub TextBox1_AfterUpdate()
    With TextBox1
    .Value = Format(.Value, "###,##0.00")
    End With
    End Sub


    Hope this answers your question,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    04-09-2005
    Location
    Multan. Pakistan
    Posts
    131

    Decimal working with formula or refrence

    hi

    Dear Leith Ross,

    Thank you for your guidance

    i past here the codes, here decimal with comma formate working with Text Boxes, txtValue, txtStax, txtTotal etc. But when i put the value in txtKgs and txtRate with 2 decimals, the value is not shown correctly, it is shown 0.01 etc instead of 16,033.50 etc

    please help me

    Option Explicit

    Private Sub cmdCancel_Click()
    End
    End Sub

    Private Sub cmdExit_Click()
    Unload Me
    End Sub

    Private Sub cmdSave_Click()
    Dim iRow As Long
    Dim ws As Worksheet

    Set ws = Worksheets("CottonPurchase")

    'find empty records

    iRow = ws.Cells(Rows.Count, 1) _
    .End(xlUp).Offset(1, 0).Row


    'check for inv no

    If Trim(Me.txtVoucher.Value) = "" Then
    Me.txtVoucher.SetFocus
    MsgBox "Please Enter Voucher No."
    Exit Sub
    End If

    ' copy the data in database

    ws.Cells(iRow, 1).Value = Me.txtVoucher
    ws.Cells(iRow, 2).Value = Me.txtVdate.Value
    ws.Cells(iRow, 3).Value = Me.txtInv
    ws.Cells(iRow, 4).Value = Me.txtDate.Value
    ws.Cells(iRow, 5).Value = Me.txtParty
    ws.Cells(iRow, 6).Value = Me.txtRegistration
    ws.Cells(iRow, 7).Value = Me.txtBales.Value
    ws.Cells(iRow, 8).Value = Me.txtKgs.Value
    ws.Cells(iRow, 9).Value = Me.txtRate.Value
    ws.Cells(iRow, 10).Value = Me.txtValue.Value
    ws.Cells(iRow, 11).Value = Me.txtStax.Value
    ws.Cells(iRow, 12).Value = Me.txtTotal.Value
    ws.Cells(iRow, 13).Value = Me.txtWtax.Value
    ws.Cells(iRow, 14).Value = Me.txtNet.Value
    ws.Cells(iRow, 15).Value = Me.txtPayable.Value

    'clear the data
    Me.txtVoucher.Value = ""
    Me.txtVdate.Value = ""
    Me.txtInv.Value = ""
    Me.txtDate.Value = ""
    Me.txtParty.Value = ""
    Me.txtRegistration.Value = ""
    Me.txtBales.Value = ""
    Me.txtKgs.Value = ""
    Me.txtRate.Value = ""
    Me.txtValue.Value = ""
    Me.txtStax.Value = ""
    Me.txtTotal.Value = ""
    Me.txtWtax.Value = ""
    Me.txtNet.Value = ""
    Me.txtPayable.Value = ""


    End Sub

    Private Sub Label14_Click()

    End Sub

    Private Sub Label2_Click()

    End Sub

    Private Sub TextBox5_Change()

    End Sub

    Private Sub txtdebit1_Change()

    End Sub

    Private Sub txtInv_Change()

    End Sub

    Private Sub txtKgs_Change()

    With txtKgs
    .Value = Format(.Value, "###,##0")


    End With

    End Sub

    Private Sub txtNet_Change()
    With txtNet
    .Value = Format(.Value, "###,##0.00")
    End With
    txtPayable = txtValue - txtWtax
    End Sub


    Private Sub txtPayable_Change()
    With txtPayable
    .Value = Format(.Value, "###,##0.00")
    End With


    End Sub

    Private Sub txtRate_Change()

    With txtRate
    .Value = Format(.Value, "###,##0")
    txtValue = Round((txtKgs) / 37.324 * txtRate, 0)
    End With

    End Sub
    Private Sub txtValue_Change()
    With txtValue
    .Value = Format(.Value, "###,##0.00")
    End With

    txtStax = Round((txtValue / 100 * 15), 0)
    txtWtax = Round((txtValue / 100 * 1), 0)
    txtdebit1 = txtValue


    End Sub

    Private Sub txtStax_Change()
    With txtStax
    .Value = Format(.Value, "###,##0.00")
    txtTotal = (txtValue * 1) + (txtStax * 1)
    End With
    End Sub


    Private Sub txtTotal_Change()
    With txtTotal
    .Value = Format(.Value, "###,##0.00")
    End With

    End Sub


    Private Sub txtVoucher_Change()

    End Sub

    Private Sub txtWtax_Change()
    With txtWtax
    .Value = Format(.Value, "###,##0.00")
    End With
    txtNet = txtTotal - txtWtax
    End Sub

    Private Sub UserForm_Click()

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1