VB2008 event works like the Onchange or Afterchange events?

时间:2015-10-30 22:52:00

标签: vb.net events onchange

I'm trying to display the information of a sale bill depending on it's barcode after writing barcode i will press ENTER So the other information should be loaded ... my problem is with the event that i will use to enter the barcode!

i tried the TEXTCHANGED,ENTER,KEYDOWN-UP-PRESS and tooo many events, but they were useless because they do not give me the chance to complete writing the full barcode !! they start checking data for every single key i press, they work only if i paste the barcode on the textbox, but this will not help me i need to write the barcode not paste it :(

i did some searches but couldn't solve the problem :( help plz :(

 Private Sub barcode_textchanged(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim cnn As New OleDb.OleDbConnection
    Dim rst As New OleDb.OleDbDataAdapter
    Dim sql As String
    Dim dt As New DataTable
    Dim lsp As New OleDb.OleDbCommand
    cnn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\database9.mdb"
    cnn.Open()
    sql = "select materialname from store where code='" & barcode.Text & "'"
    rst = New OleDb.OleDbDataAdapter(sql, cnn)
    rst.Fill(dt)

    matname.Text = dt.Rows(0).Item("materialname")
    lsp = New OleDb.OleDbCommand("select last(saleprice)from store where code='" & barcode.Text & "'", cnn)
    Dim sp As Integer = lsp.ExecuteScalar
    sprice.Text = sp
    qty.Text = 1
    totalmat.Text = sprice.Text * qty.Text
    ListView1.Items(0).Text = matname.Text
    ListView1.Items(0).SubItems(1).Text = qty.Text
    ListView1.Items(0).SubItems(2).Text = Val(sprice.Text * qty.Text)



End Sub

0 个答案:

没有答案