Tendo Sai
Tendo Sai

Reputation: 29

Excel as database, search from textbox and show info to specific textbox accordingly VB.NET

I work with one of my project where I have list of d:\Project\customer.xls. In the list there is No, Name, Sex, Telephone, Date of Birth, ID Card, IA Code. Therefore, I design a search button by type in "Phone Number" and with success search it will show Name, DoB, ID card and IA code on the text box accordingly.

  1. is it possible to directly take value from the cell in excel and show it in textbox without using datatable?
  2. if it is not possible, and i must use datatable to import excel to it first, can i hide it from view as if it is non exist?

This link help me with import from excel to datatable but from here ... how can i get specific data to show in textbox accordingly?

Upvotes: 1

Views: 302

Answers (1)

AJD
AJD

Reputation: 2438

Using VBA (not VB.Net) you can set the <TextBoxName>.Text = ThisWorkbook.<Sheet>.Range(<TheCellAddress>)

You can use .Text or .Value as you see fit on both the textbox and the range. In addition, you can also use .Range(...).Value, but this is the default response anyway if you don't use a Set <variable>= ... type statement.

If you are using VB.Net through the interop assemblies, you can do the same thing. The VB.Net language has some more efficient and cleaner ways to manipulate strings.

Upvotes: 1

Related Questions