HELP!! Visual Basic - Library Loan System.

kennedysee
01-13-2008, 03:00 AM
Hi guys,

I am facing problem with visual basic. I'm quite new to this programming language and had project on it. I'm doing on Library Loan System.

How i want the program to work,

1) user type a keyword on textbox(txtSearch) to search the book from the database.

2) It will display the search found in a listbox(lbSearch).

3) After displaying the search, i will click on a button; LoanButton.

4) It will remove that particular book on the listbox(lbSearch) and add to another listbox(lbLoan).


I am facing problems with this few points, can anyone willing to assist me? Thank You.

Qua
01-13-2008, 04:10 AM
First of all, you would have to construct a sql query from your search word. A typical query to extract data from a database is:
SELECT * FROM [TableName] Where [FieldName] = SearchValue

You can add and remove items from a listbox by using the methods Remove/Add found under Items.

DougT
01-13-2008, 04:18 AM
I think you missed a step out:

2a) After populating the ListBox the user selects one from the list

then 3) becomes

3) After the user selects one, I will click on a Button; LoanButton

You may also like to think about what to do if the user makes a mistake and selects the wrong book - you'll need to move it from lbLoan back into lbSearch.

In terms of what you need to look at, code wise:

(a) The SQL SELECT statement, the LIKE operator and the WHERE clause
eg

strSQL = "SELECT * FROM Books WHERE BookTitle LIKE '%" & txtSearch.Text & "%'"

which will search the Table named BookTitles and return a set of records where whatever is in the txtSearch appears in the records. (The "%" is the 'Wild Character' used by Access.) If you wanted an exact match then you'd use the "=" Operator and remove the "%"s.

(b) The methods for adding and removing items from a ListBox (AddItem and RemoveItem) and the ListIndex property. You may also need to use the ListBox_Click event.

EDIT: I see that qua beat me to it.

kennedysee
01-13-2008, 05:07 AM
Thanks for the quick responce. :)

Can i do a simple database? whereas the data keep in a notepad?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum