|
Ralf and Richard,
Thanks for replying. I just wanted to update you and let you know that my confusion stemmed from a lack of understanding on interfaces in themselves. I've since familiarized myself a bit better and have a grasp on the issue I was having.
Thanks!
|
|
|
|
|
Hi,
I am using Visual Studio 2010 and programming in vb. I have a txtbox name "txtFirstName" and a button called "btnCommit". Once the user has added a name to FirstName and clicked the button I need the programme to check the access database tabel to see if the name exists or not. How do I go about doing this?
Thank you in advance for your assistance.
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDb.OleDbConnection
Dim inc As Integer
Dim MaxRows As Integer
Dim dbProvider As String
Dim dbSource As String
Dim MyDocumentsFolder As String
Dim TheDatabase As String
Dim FullDatabasePath As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
TheDatabase = "/AddressBook.mdb"
MyDocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
FullDatabasePath = MyDocumentsFolder & TheDatabase
dbSource = "Data Source = " & FullDatabasePath
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT *FROM tblContacts"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
con.Close()
MaxRows = ds.Tables("AddressBook").Rows.Count
inc = -1
End Sub
Private Sub NavigateRecords()
txtFirstName.Text = ds.Tables("AddressBook").Rows(inc).Item(1)
txtSurname.Text = ds.Tables("AddressBook").Rows(inc).Item(2)
cboxHouse.Checked = ds.Tables("AddressBook").Rows(inc).Item(3)
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
If inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MessageBox.Show("No More Rows")
End If
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
ElseIf inc = -1 Then
MessageBox.Show("No Records Yet")
ElseIf inc = 0 Then
MessageBox.Show("First Record")
End If
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
NavigateRecords()
End If
End Sub
Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
If inc <> 0 Then
inc = 0
NavigateRecords()
End If
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("AddressBook").Rows(inc).Item(1) = txtFirstName.Text
ds.Tables("AddressBook").Rows(inc).Item(2) = txtSurname.Text
ds.Tables("AddressBook").Rows(inc).Item(3) = cboxHouse.CheckState
da.Update(ds, "AddressBook")
MessageBox.Show("Data updated")
End Sub
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
btnCommit.Enabled = True
btnAddNew.Enabled = False
btnUpdate.Enabled = False
btnDelete.Enabled = False
txtFirstName.Clear()
txtSurname.Clear()
txtFirstName.Focus()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True
btnDelete.Enabled = True
inc = 0
NavigateRecords()
End Sub
Private Sub btnCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("AddressBook").NewRow()
dsNewRow.Item("FirstName") = txtFirstName.Text
dsNewRow.Item("Surname") = txtSurname.Text
dsNewRow.Item("House") = cboxHouse.CheckState
ds.Tables("AddressBook").Rows.Add(dsNewRow)
MaxRows = MaxRows + 1
MessageBox.Show("New Record added to the Database")
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True >
btnDelete.Enabled = True
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True
btnDelete.Enabled = True
inc = 0
da.Update(ds, "AddressBook")
NavigateRecords()
End If
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
MessageBox.Show("Operation Cancelled")
Exit Sub
End If
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("AddressBook").Rows(inc).Delete()
MaxRows = MaxRows - 1
inc = 0
da.Update(ds, "AddressBook")
NavigateRecords()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Application.Exit()
End Sub
End Class
|
|
|
|
|
Just query the database for a record that contains the entered name.
|
|
|
|
|
Thank you for your response.
How do I go about doing this. I am not good at coding...
|
|
|
|
|
Member 12816539 wrote: I am not good at coding Then now would be a good time to study the documentation for the database you are using. Especially commands to insert, update and select records.
|
|
|
|
|
Hello !
In a vb.net 2013 application , I have a treeview when I need to have drag and drop operations .
But I have a case when the user begin to drag , but before drop to destination node I need to test something and if a condition is false , the entire operation should undo .
How can I do this ?
Thank you !
|
|
|
|
|
It would be easier if you showed your code, so hope this helps.
The normal process is in the DragEnter event you set e.effects = to the drag and drop you will allow (move, copy etc). Then in the DragDrop event determine your condition and set e.Effect = DragDropEffects.None if it is not allowed, else execute the drop code.
|
|
|
|
|
can i use wavelet transform to inhance but using the visual basic not math lab
i am student i donot know if i can use this way in vb
|
|
|
|
|
Sure, you just have to implement the transform yourself in code.
|
|
|
|
|
Would it be hard for someone with no programming knowledge to make an application that simply disables drag from a mouse when you hold left click or just left click in general.
With the option to hold a set key down to momentarily enable leftclick-dragging until you release the key.
|
|
|
|
|
Yes it would be very hard; especially in Visual Basic.
|
|
|
|
|
Don't worry i found a resolution. Thanks.
|
|
|
|
|
Hello !
Is there any way to use and manage an usb barcode reader in a vb.net program ?
What I want to do is :
-- Distinguish reading from barcode reader and typing from keyboard
-- Allow or deny displaying the barcode in a textbox after is read ( I mean when that textbox is focused and active at that moment )
--- Capture the barcode that is read even when no textbox is currently focused or active control at that moment ( I mean when a specific form is open , and a read from barcode reader was made , I should be able to capture the barcode in a variable )
Thank you !
Update
1) Actually , I've read somewhere on internet that to distinguish between reading from barcode reader and typing on keyboard is to keep track on keystrokes timing , for example if a stream of characters are read in less than 100ms ( or another reasonable time) then this mean a barcode reader was made. But I don't know how can I do this ?
2) About the reading in background when no textbox is focused , I've found this article : https://msdn.microsoft.com/en-us/library/ms171538%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 . Do you think that catching a barcode read at the form level , before reaching the control can help resolve this ?
modified 21-Oct-16 0:05am.
|
|
|
|
|
This has nothing to do with Visual Basic. You are asking for information on how your device works. That information should be in the manufacturer's documents.
|
|
|
|
|
We're talking for general usb barcode readers that act like a keyboard.
|
|
|
|
|
Then the same applies as for any keyboard.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, and the behaviour of the barcode reader is specific to its design & manufacture. So you still need to read the manual to see how it presents itself and its data.
|
|
|
|
|
What about programs that can work with any kind of usb barcode readers ? so they are general and what they need is only to plug the barcode reader.
|
|
|
|
|
Yes, and what happens then?
|
|
|
|
|
The barcode reader is working as expected.
I've seen some programs ( of course I don't have the code ) that can use any type of USB barcode readers ( without any special configuration ) and can distinguish between 2 modes ( for example focusing a textbox when I type with keyboard nothing is displayed , when I read with barcode reader the barcode is displayed ). And also if I focus a listbox or another control in the form, and read with barcode reader , the barcode is read and displayed in the right textbox without focusing it.And I've tested these programs even with cheap no name Chinese barcode readers and always work perfectly.
So it seems a way should exist.
|
|
|
|
|
desanti wrote: So it seems a way should exist. Simple; learn C++ and write a generic device driver.
..but in VB.NET, you are limited to what the software that is installed for the device allows you to do.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
These are USB barcode readers that are configured to act like keyboards. No software are needed to install for these devices. Windows has that "Generic drivers" built in.So I can plug different kinds of these barcode readers , at the same Pc and they use the same driver built in on windows.
So these barcode readers are like keyboards with only 1 difference : They can "type" much more chars at a small time compared with typing on keyboard.
I hope that someone can help me working on this idea.
|
|
|
|
|
Yes, Windows already has multiple generic device-drivers. The functionality provided is exactly that, it fits most needs.
If you need more, you contact the manufacturer and see if they have an SDK;
..but from VB? Good luck there
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Then those programs must be communicating direct to the device(s) via the USB interface. Alternatively, as Dave K already suggested, the device sends extra data to identify itself. Google (as usual) is the place to start your research.
|
|
|
|
|
I've tested and it seems that these barcode readers only send a list of chars and an "ENTER" at the end. So no special characters.
|
|
|
|