Start New Discussion within our Software Development Community

This is my code:

Private Sub cmdHitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdHitung.Click
        Dim tempBASIC As String

        If strChrDec = "." Then
            strFormatDec = "#,##0.00;(#,##0.00)"
            formatSAVE = "############0.#0"
        Else
            strFormatDec = "#.##0,00;(#.##0,00)"
            formatSAVE = "############0,#0"
        End If

        If Val(Format(Convert.ToDouble(txtGajiPokok.Text), formatSAVE)) > 0 Then
            If Trim(txtGPPilih.Text) = "H" Then
                tempBASIC = Val(Format(Convert.ToDouble(txtGajiPokok.Text), formatSAVE)) * 30
            Else
                tempBASIC = Val(Format(Convert.ToDouble(txtGajiPokok.Text), formatSAVE))
            End If
            txtLemburTetap.Text = Format(((tempBASIC / 173) * 1.5 * 20) + ((tempBASIC / 173) * 2 * 20), strFormatDec)
        End If
    End Sub

Example i'm input 150000, But result 60.69364. Not i want. I want to 60.693,64. Please help me thank's

This should do the trick:

Imports System.Globalization

Public Class frmFormat

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim nfi As NumberFormatInfo = New CultureInfo("en-US", False).NumberFormat
		nfi.NumberDecimalSeparator = ","
		nfi.NumberGroupSeparator = "."
		Dim tempBASIC As String = "150000"
		Dim decResult As Decimal = ((tempBASIC / 173) * 1.5 * 20) + ((tempBASIC / 173) * 2 * 20)
		MessageBox.Show(decResult.ToString("N", nfi))
	End Sub
End Class
This article has been dead for over six months. Start a new discussion instead.