0

this coding working.
but this coding simple coding..
can anyone give idea how to make this coding looking nice ?

Imports System.Data

Public Class frmANGGARANBARU

    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter
    Dim sql As String

    Private Sub frmANGGARANBARU_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'SISTEM_DATABASEDataSet.KadarPremium' table. You can move, or remove it, as needed.
        Me.KadarPremiumTableAdapter.Fill(Me.SISTEM_DATABASEDataSet.KadarPremium)
        'TODO: This line of code loads data into the 'SISTEM_DATABASEDataSet.PelanFaedah' table. You can move, or remove it, as needed.
        Me.PelanFaedahTableAdapter.Fill(Me.SISTEM_DATABASEDataSet.PelanFaedah)


        con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = H:\PROJEK\New Sistem\SISTEM_DATABASE.mdb"
        con.Open()
        con.Close()


    End Sub

    Private Sub ShowPelan()
        sql = "SELECT * FROM PelanFaedah"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "PelanFaedah")

        txtKHUKK.Text = ds.Tables("PelanFaedah").Rows(cmbPelan.SelectedIndex).Item(1)
        txt36P.Text = ds.Tables("PelanFaedah").Rows(cmbPelan.SelectedIndex).Item(2)
        txtPHH.Text = ds.Tables("PelanFaedah").Rows(cmbPelan.SelectedIndex).Item(3)
        txtPKKAAK.Text = ds.Tables("PelanFaedah").Rows(cmbPelan.SelectedIndex).Item(4)
    End Sub

    Private Sub cmbPelan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPelan.SelectedIndexChanged
        ShowPelan()
    End Sub

    Private Sub cmbPremium_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPremium.SelectedIndexChanged
        sql = "SELECT * FROM KadarPremium"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "KadarPremium")

        If cmbPelan.SelectedIndex = "1" Then
            txtPremium.Text = ds.Tables("KadarPremium").Rows(cmbPremium.SelectedIndex).Item(1)
        ElseIf cmbPelan.SelectedIndex = "2" Then
            txtPremium.Text = ds.Tables("KadarPremium").Rows(cmbPremium.SelectedIndex).Item(2)
        ElseIf cmbPelan.SelectedIndex = "3" Then
            txtPremium.Text = ds.Tables("KadarPremium").Rows(cmbPremium.SelectedIndex).Item(3)
        ElseIf cmbPelan.SelectedIndex = "4" Then
            txtPremium.Text = ds.Tables("KadarPremium").Rows(cmbPremium.SelectedIndex).Item(4)
        ElseIf cmbPelan.SelectedIndex = "5" Then
            txtPremium.Text = ds.Tables("KadarPremium").Rows(cmbPremium.SelectedIndex).Item(5)
        ElseIf cmbPelan.SelectedIndex = "6" Then
            txtPremium.Text = ds.Tables("KadarPremium").Rows(cmbPremium.SelectedIndex).Item(6)
        ElseIf cmbPelan.SelectedIndex = "7" Then
            txtPremium.Text = ds.Tables("KadarPremium").Rows(cmbPremium.SelectedIndex).Item(7)
        End If
    End Sub
End Class
3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by ggl0rd
0

if its just about the "look" of the code then thats how my style would look like:

Imports System.Data

Public Class frmANGGARANBARU

    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter
    Dim sql As String

    Private Sub frmANGGARANBARU_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KadarPremiumTableAdapter.Fill(Me.SISTEM_DATABASEDataSet.KadarPremium)
        PelanFaedahTableAdapter.Fill(Me.SISTEM_DATABASEDataSet.PelanFaedah)
        con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = H:\PROJEK\New Sistem\SISTEM_DATABASE.mdb"
        con.Open()
        con.Close()
    End Sub

    Private Sub ShowPelan()
        sql = "SELECT * FROM PelanFaedah"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "PelanFaedah")

        With ds.Tables("PelanFaedah").Rows(cmbPelan.SelectedIndex)
            txtKHUKK.Text = .Item(1)
            txt36P.Text = .Item(2)
            txtPHH.Text = .Item(3)
            txtPKKAAK.Text = .Item(4)
        End With

    End Sub

    Private Sub cmbPelan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPelan.SelectedIndexChanged
        ShowPelan()
    End Sub

    Private Sub cmbPremium_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPremium.SelectedIndexChanged
        sql = "SELECT * FROM KadarPremium"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "KadarPremium")

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

    End Sub
End Class
0

this coding simple..
many connection like datasource also me use propertise setting..
like combobox ..

thanks geekbychoice..
i want try u coding..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.