anyone can help me fix this coding..
this coding output is string output..
but i want output in double..

Private Sub OutputPremium()

        With ds.Tables("KadarPremium").Rows(cmbPremium.SelectedIndex)
            Select Case cmbPelan.Text
                Case (1)
                    lblPremium.Text = .Item("20TP1")
                Case (2)
                    lblPremium.Text = .Item("20TP2")
                Case (3)
                    lblPremium.Text = .Item("20TP3")
                Case (4)
                    lblPremium.Text = .Item("20TP4")
                Case (5)
                    lblPremium.Text = .Item("20TP5")
                Case (6)
                    lblPremium.Text = .Item("20TP6")
                Case (7)
                    lblPremium.Text = .Item("20TP7")
                Case Else
                    'whatever you want to do here
            End Select

            If cmbJPembayaran.Text = "Bulanan" Then
                lblPremiumJP.Text = lblPremium.Text \ 12
            ElseIf cmbJPembayaran.Text = "3 Bulan" Then
                lblPremiumJP.Text = (lblPremium.Text \ 12) * 3
            ElseIf cmbJPembayaran.Text = "6 Bulan" Then
                lblPremiumJP.Text = lblPremium.Text \ 2
            Else
                'whatever
            End If

        End With

    End Sub

Recommended Answers

All 7 Replies

If cmbJPembayaran.Text = "Bulanan" Then
                lblPremiumJP.Text = CDbl(lblPremium.Text) \ 12
            ElseIf cmbJPembayaran.Text = "3 Bulan" Then
                lblPremiumJP.Text = (CDbl(lblPremium.Text) \ 12) * 3
            ElseIf cmbJPembayaran.Text = "6 Bulan" Then
                lblPremiumJP.Text = CDbl(lblPremium.Text) \ 2
            Else
                'whatever
            End If

it no working Geek..
help plss

for u know, that data cmb is take from database..

sqlPelan = "SELECT * FROM PelanFaedah"
        da = New OleDb.OleDbDataAdapter(sqlPelan, con)
        da.Fill(ds, "PelanFaedah")

        sqlPremium = "SELECT * FROM KadarPremium"
        da = New OleDb.OleDbDataAdapter(sqlPremium, con)
        da.Fill(ds, "KadarPremium")

do u get an exception? if so please post it here.

exception like error?
no, the output still show..
but not show in double only.

and as what does it out put? give us some example out put!

the output should be like
123.39


erm or i think from

Case (1)
                    lblPremium.Text = .Item("20TP1")

i want make lblPremium.text take data(value like 2030) from database,
how to set lblPremium as double?

thanks geek for u help..
my problem solved

With ds.Tables("KadarPremium").Rows(cmbPremium.SelectedIndex)
            Select Case cmbPelan.Text
                Case 1
                    txtPremium.Text = .Item("20TP1")
                Case 2
                    txtPremium.Text = .Item("20TP2")
                Case 3
                    txtPremium.Text = .Item("20TP3")
                Case 4
                    txtPremium.Text = .Item("20TP4")
                Case 5
                    txtPremium.Text = .Item("20TP5")
                Case 6
                    txtPremium.Text = .Item("20TP6")
                Case 7
                    txtPremium.Text = .Item("20TP7")
                Case Else
                    'whatever you want to do here
            End Select
        End With

        Select Case cmbJPembayaran.Text
            Case "Bulanan"
                txtPremiumJP.Text = String.Format("{0:n2}", txtPremium.Text / 12)
            Case "3 Bulan"
                txtPremiumJP.Text = String.Format("{0:n2}", (txtPremium.Text / 12) * 3)
            Case "6 Bulan"
                txtPremiumJP.Text = String.Format("{0:n2}", txtPremium.Text / 2)
            Case Else
        End Select
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.