mengatasi error karna kesalahan memasukan huruf ke tipe data angka di vb.net

Try
Dim hasil As Integer = 0
hasil = TextBox7.Text Or textbox12.Text
MsgBox(“masukan huruf”)
Catch ex As Exception
MsgBox(“Masukan Data Id Dan Kodemk Dengan angka”, MsgBoxStyle.Information, “peringatan”)
Exit Sub

End Try

**untuk kesalahan sebaliknya silahkan diganti dim hasil integer menjadi dim hasil as string, untuk yang lainya silahkan di liat di tulisan saya yang berjudul macam jenis variabel**

kasih komentnya y….

Advertisements

membuat widget baru di wordpress

Tambahkan tulisan di bawah ke function.php tema yang di gunakan:

 

function arphabet_widgets_init() {

	register_sidebar( array(
		'name' => 'Home right sidebar',
		'id' => 'home_right_1',
		'before_widget' => '<div>',
		'after_widget' => '</div>',
		'before_title' => '<h2 class="rounded">',
		'after_title' => '</h2>',
	) );
}

 

masukan text di bawah ke halaman yang di inginkan untuk menampilkan widget:

<?php dynamic_sidebar( 'sidebar-1' ); ?>

filter untuk edit tulisan add to cart di woocommerce

masuk ke functions.php lalu tulis

 

 

add_filter( ‘add_to_cart_text’, ‘woo_custom_cart_button_text_single’ ); // < 2.1
add_filter( ‘woocommerce_product_single_add_to_cart_text’, ‘woo_custom_cart_button_text_single’ ); // 2.1 +
function woo_custom_cart_button_text_single() {
return __( ‘Beli’, ‘woocommerce’ );
}

add_filter( ‘add_to_cart_text’, ‘woo_custom_cart_button_text_archive’ ); // < 2.1
add_filter( ‘woocommerce_product_add_to_cart_text’, ‘woo_custom_cart_button_text_archive’ ); // 2.1 +
function woo_custom_cart_button_text_archive() {
return __( ‘Beli’, ‘woocommerce’ );
}

insert data dari datagridview

contoh sub insert

sub insert1

dim dt as new datatabel

dim ocmd as new oledbcommand

Try
            For i As Integer = 0 To Form1.dt.Rows.Count – 2

                Form1.ocmd.Connection = Form1.con
                Form1.ocmd.CommandType = CommandType.Text
                Form1.ocmd.CommandText = “exec insertbarang ” & DataGridView1.Rows(i).Cells(0).Value & “,'” & DataGridView1.Rows(i).Cells(1).Value & “‘,'” & DataGridView1.Rows(i).Cells(2).Value & “‘,'” & DataGridView1.Rows(i).Cells(3).Value & “‘”
                Form1.ocmd.ExecuteNonQuery()
            Next
            MsgBox(“data di tambah”)
        Catch ex As Exception
            MsgBox(“error: “, ex.Message)
        End Try

end sub

mengalikan data dari 2 cell di dgv dan hasil dari pekalian itu di tampilkan ke cell lainnya

buat formdatagridview dengan akhiran “.CellEndEdit”

Private Sub Datagridview1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
        DataGridView1.Rows(e.RowIndex).Cells(6).Value = DataGridView1.Rows(e.RowIndex).Cells(3).Value * DataGridView1.Rows(e.RowIndex).Cells(5).Value
      
    End Sub

Membuat penomoran otomatis di textbox

contoh

buat sebuah sub dengan nama “kode_otomatis”

sub kode_otomatis

ocmd.CommandText = “select * from penjualan order by faktur”
        odr = ocmd.ExecuteReader
        odr.Read()
        If Not odr.HasRows Then
            TextBox1.Text = “f00001”
        Else
            TextBox1.Text = Val(Microsoft.VisualBasic.Mid(odr.Item(“faktur”).ToString, 6, 2)) + 1
            If Len(TextBox1.Text) = 1 Then
                TextBox1.Text = “f0000” & TextBox1.Text & “”
            ElseIf Len(TextBox1.Text) = 2 Then
                TextBox1.Text = “f000” & TextBox1.Text & “”
            ElseIf Len(TextBox1.Text) = 3 Then
                TextBox1.Text = “f00” & TextBox1.Text & “”
            ElseIf Len(TextBox1.Text) = 4 Then
                TextBox1.Text = “f0” & TextBox1.Text & “”
            ElseIf Len(TextBox1.Text) = 5 Then
                TextBox1.Text = “f” & TextBox1.Text & “”

            End If
        End If

end sub

menampilkan database ke combobox

 Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Dim ocon As New OleDbConnection
        Dim ocmd As New OleDbCommand
        Dim oda As New OleDbDataAdapter
        Dim ds As New DataSet
        Dim dt As New DataTable
        Dim odr As OleDbDataReader

        ocon.ConnectionString = “Provider=sqloledb ;data source=.\sqlexpress; initial catalog=namadatabase; user id=nama_user;password=Rahasia;”
        ocmd.Connection = ocon
        ocon.Open()
        ocmd.CommandType = CommandType.Text

        ocmd.CommandText = “select * from kategori where kode_kategori= ‘” & ComboBox2.Text & “‘”
        odr = ocmd.ExecuteReader
        odr.Read()
        If odr.HasRows Then
            TextBox13.Text = odr.Item(“nama_kategori”)
        End If
    End Sub