Вы находитесь на странице: 1из 53

Ads by Google

VB6 to C#

Text Control

Ado Net

SQL Tutorials
Search

Visual Basic 6 (VB6)


Home Tutorials

Using ADO and the ListView control


Level:

Better Draq5 & Draq7


RedDots 1&2: Counterstains More Nuclear SpecificThan Draq5 & Draq7
www.biotium.com
Written By TheVBProgramer. (Customer Table Maintenance Example) This VB6 tutorial demonstrates uses of ADO not covered in other tutorials on this site. The sample project presented here is a simple "one-table" database application. It works with a table of customer data (name, address, phone, etc.) and allows the user to view, add, update, and delete customer records. Also, this sample project uses the ListView control to display the records that the application will be working with. The use of the ListView control is covered at the end of this topic. The sample application uses an MS-Access database called Cust.mdb, consisting of one table called Customer. The columns of the table are defined as follows:

Column Name

Data Type

CustID

Number (Long Integer)

LastName

Text (50)

FirstName

Text (50)

Address

Text (50)

City

Text (25)

State

Text (2)

Zip

Text (5)

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

PhoneNumber

Text (10)

Screen-shots of the sample application are shown below. Initially, this screen is in "read-only" mode; only the list portion is active. The data entry fields on the bottom half of the screen are grayed out are not enterable. The buttons to add, update, and delete are available; the buttons to save or cancel are not available. A screen-shot of the screen in this state is shown below:

To add a customer, click the "Add" button. This will enable the fields on the bottom half of the screen. The buttons to add, update, and delete will become unavailable; the buttons to save or cancel will be available. A screen-shot of the screen in this state is shown below:

K SK L ~ J L ~J ~J J J S

O LRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

You can then enter the values for the new record:

When you are done entering data into the fields, click the Save button, which will cause the new record to be added to the list and will cause the screen to revert back to its initial "read-only" state. A screen-shot of the screen in this state is shown below:

K SK L ~ J L ~J ~J J J S

PLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

To modify data for an existing customer record, click the customer record in the list to highlight it and click the "Update" button. This will enable the fields on the bottom half of the screen. The buttons to add, update, and delete will become unavailable; the buttons to save or cancel will be available. When you are done changing the data in the fields, click the Save button, which will cause the record to be updated in the list and will cause the screen to revert back to its initial "read-only" state. To delete a customer record, click the customer record in the list to highlight it and click the "Delete" button. The following message will be displayed:

Responding "Yes" to the confirmation prompt will cause the applciation to delete the record and remove it from the list. To exit the Customer Maintenance screen, click the "Close" button when the screen is in its "read only" state. The Close button will not be available when you have an "add" or "update" pending. If you attempt to close the screen with the Windows "X" button while you have an "add" or "update" pending, the following message will be displayed:

K SK L ~ J L ~J ~J J J S

Q LRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Highlights of the code, as it relates to ADO, are presented below. Three ADO object variables (representing and ADO Connection, Command, and Recordset, respectively) are declared at the form level. This a one-form application (with a handful of supporting modules), so in this case, formlevel scope is serviceable. PiaembCn rvt ojon PiaembCd rvt ojm PiaembRt rvt ojs A AOBCneto s DD.oncin A AOBCmad s DD.omn A AOBRcrst s DD.eode

The database is opened in the "ConnectToDB" Sub. First, the Connection object variable mobjConn is instantiated by setting it to New ADODB.Connection. Then the ConnectionString property is set. A difference between this sample application and the ones in the previous topic is that this application uses a DSN-less connection meaning that the steps we went through in the previous ADO examples to set up a DSN are NOT required here. As you may recall from the previous examples, using a DSN connection in your code requires that a DSN be set up on the computer that your program is running on. This restricts where your code can run. On the other hand, a DSN-less connection specifies all the parameters necessary to connect to the database and allows your program to be run on different machines without having to set up a new DSN. In the case of our sample application, two parameters are required to connect to the Access database: first, the Provider parameter (which specifies Microsoft.Jet.OLEDB.4.0; and second, the Data Source parameter, which specifies the full path of the Access mdb file. In the case of this sample application, it is expected that the mdb file reside in the same folder as the VB project files, or, if this application is compiled, the database should reside in the same location as the executable (.exe) file. The application path is returned by the programmer-defined function GetAppPath (which contains the code to use the App.Path built-in function and append the backslash to it if necessary). Note that the syntax of the ConnectionString requires each parameter name to be followed by an equal sign (=) followed by the value. Each parameter name / value pair is separated by a semicolon (;). Embedded spaces in the parameter names and values are evaluated properly. For example, if your application was located in the folder "C:\My VB Apps\Database Apps", the content of the ConnectionString would be: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My VB Apps\Database Apps\Cust.mdb" Note: If you connect to other databases such as Oracle or SQL Server, different parameters (such as Server, UID, and PWD) will be required; however the syntax rules described above still apply. After the ConnectionString has been set, the Open method is then used to open the connection to the database. The Command object mobjCmd is then instantiated by setting it to New ADODB.Command. The Command object represents a command to execute against a database. Command objects are often used to create recordsets or execute action queries. A Command object must use a Connection, either by establishing its own, or by using an existing connection. To use an existing connection, set the Command object's ActiveConnection property to the open Connection object, as shown in the code below. This routine also sets the Command object's CommandType property, which tells ADO how to interpret the contents of the CommandText property (which we will be setting to SQL statements in various places in the application). Since this application will always be passing the Command object a textual SQL string, the value is set to the constant adCmdText (other possible values for CommandType include adCmdTable, which would cause the CommandText to be evaluated as a database table, and
K SK L ~ J L ~J ~J J J S RLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

adCmdStoredProc, which would cause the CommandText to evaluated as the name of a stored procedure). '---------------------------------------------------------------------------PiaeSbCnetoB) rvt u oncTD( '---------------------------------------------------------------------------StmbCn =NwAOBCneto e ojon e DD.oncin mbCn.oncintig="rvdrMcootJtOEB40"_ ojonCnetoSrn Poie=irsf.e.LD..; &"aaSuc= _ Dt ore" &GtpPt _ eApah &"utmb Cs.d" mbCn.pn ojonOe StmbCd=NwAOBCmad e ojm e DD.omn StmbCdAtvCneto =mbCn e ojm.cieoncin ojon mbCdCmadye=aCdet ojm.omnTp dmTx EdSb n u In the "LoadCustomerListView" Sub, the contents of the Customer table is loaded into the listview. First, a SQL SELECT statement is built in the String variable strSQL. The String variable strSQL is then assigned to the CommandText property of the Command object with the statement mbCdCmadet=srQ ojm.omnTx tSL Following this, the Recordset object mobjRst is then populated by assigning it the result of the Execute method of the Command object in the statement StmbRt=mbCdEeue e ojs ojm.xct Note: A Recordset object created with the Command.Execute method always creates a forward-only, read-only recordset ("firehose" cursor). The code then loops through the recordset, populating each row of the listview. At the bottom of the Sub, the recordset object is set to Nothing, which disconnects it from the database. All manipulations of the data from the point on are handled through the listview, until it is time to update or insert a record back into the database. It should be noted that the process of loading the entire contents of a table into a listview in this fashion works well for tables with a small number of rows you do not want to do this for recordsets containing thousands of rows. '---------------------------------------------------------------------------PiaeSbLaCsoeLsVe( rvt u odutmritiw) '---------------------------------------------------------------------------DmsrQ i tSL DmojurI i bCrL Dmsri i tZp Dmsrhn i tPoe A Srn s tig A LsIe s ittm A Srn s tig A Srn s tig

srQ ="EETFrtae _ tSL SLC isNm" &" &" &" &" ,LsNm"_ atae ,Ades _ drs" ,Ct"_ iy ,Sae _ tt"
SLRP

K SK L ~ J L ~J ~J J J S

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

&" &" &"

,Zp _ i" ,Poeubr _ hnNme" ,CsI"_ utD

&" FO Csoe "_ RM utmr &"ODRB LsNm"_ RE Y atae &" ,Frtae isNm"

mbCdCmadet=srQ ojm.omnTx tSL StmbRt=mbCdEeue e ojs ojm.xct lwutmrLsIesCer vCsoe.ittm.la Wt mbRt ih ojs D Utl.O o ni EF srhn =!hnNme &" tPoe Poeubr " I Lnsrhn)>0Te f e(tPoe hn srhn =""&Lf$srhn,3 &" "_ tPoe ( et(tPoe ) ) &Md(tPoe 4 3 &""_ i$srhn, , ) &Rgt(tPoe 4 ih$srhn, ) EdI n f StojurI=lwutmrLsIesAd,,!isNm &",,"ut" e bCrL vCsoe.ittm.d( Frtae " Css) ojurISbtm(lgUTLS_D)=!atae&" bCrL.uIesmnCS_ATIX LsNm " ojurISbtm(lgUTAD_D)=!drs &" bCrL.uIesmnCS_DRIX Ades " ojurISbtm(lgUTCT_D)=!iy&" bCrL.uIesmnCS_IYIX Ct " ojurISbtm(lgUTS_D)=!tt &" bCrL.uIesmnCS_TIX Sae " ojurISbtm(lgUTZPIX =!i &" bCrL.uIesmnCS_I_D) Zp " ojurISbtm(lgUTPOEIX =srhn bCrL.uIesmnCS_HN_D) tPoe ojurISbtm(lgUTI_D)=Ct(CsI) bCrL.uIesmnCS_DIX Sr!utD .oeet MvNx Lo op EdWt n ih Wt lwutmr ih vCsoe I .ittm.on >0Te f LsIesCut hn St.eetdtm=.ittm() e SlceIe LsIes1 lwutmrIeCik.eetdtm vCsoe_tmlc SlceIe EdI n f EdWt n ih StojurI=Ntig e bCrL ohn StmbRt=Ntig e ojs ohn EdSb n u In the "cmdSave_Click" event procedure, depending on whether an add or update has been initiated, a SQL INSERT or UPDATE statement is built with the String variable strSQL. The String variable strSQL is then assigned to the CommandText property of the Command object with the statement mbCdCmadet=srQ ojm.omnTx tSL The INSERT or UPDATE action query is then executed with the statement mbCdEeue ojm.xct
K SK L ~ J L ~J ~J J J S TLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Note that the record ID plays an important role. For an add, the new record ID is obtained by calling the programmerdefined function GetNextCustID, which is described a little later below. For an update, the record ID of the currently selected item in the listview is used in the UPDATE statement to update the record. In either case, the contents of the listview is updated approriately to reflect the insert or update. '---------------------------------------------------------------------------PiaeSbcdaeCik) rvt u mSv_lc( '---------------------------------------------------------------------------Dmsrhn i tPoe DmlgDil i nIFed DmsrQ i tSL A Srn s tig A Ln s og A Srn s tig

DmojeLsIe A LsIe i bNwittm s ittm

I NtVldtFrFed Te Ei Sb f o aiaeomils hn xt u srhn =ttraTx &ttrxTx &ttieTx tPoe xAe.et xPf.et xLn.et I mtMitoe="D"Te f sranMd AD hn lgDil =GtetutD) nIFed eNxCsI( srQ ="NETIT Csoe( CsI" tSL ISR NO utmr utD srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &lgDil tSL tSL nIFed srQ =srQ &" ' &Rpae(xFrtTx,"" "')&"" tSL tSL , " elc$ttis.et ', '" ' srQ =srQ &" ' &Rpae(xLs.et "" "')&"" tSL tSL , " elc$ttatTx, ', '" ' srQ =srQ &" ' &Rpae(xAd.et "" "')&"" tSL tSL , " elc$ttdrTx, ', '" ' srQ =srQ &" ' &Rpae(xCt.et "" "')&"" tSL tSL , " elc$ttiyTx, ', '" ' srQ =srQ &" ' &tttt.et&"" tSL tSL , " xSaeTx ' srQ =srQ &" ' &tti.et&"" tSL tSL , " xZpTx ' srQ =srQ &" ' &srhn &"" tSL tSL , " tPoe ' srQ =srQ &"" tSL tSL ) StojeLsIe =lwutmrLsIesAd,,ttis.et ,"ut" e bNwittm vCsoe.ittm.d( xFrtTx, Css) PpltLsIe ojeLsIe ouaeittm bNwittm Wt ojeLsIe ih bNwittm .uIesmnCS_DIX =Ct(nIFed Sbtm(lgUTI_D) SrlgDil) .nueiil EsrVsbe EdWt n ih StlwutmrSlceIe =ojeLsIe e vCsoe.eetdtm bNwittm StojeLsIe =Ntig e bNwittm ohn Es le lgDil =Cn(vCsoe.eetdtmSbtm(lgUTI_D) nIFed LglwutmrSlceIe.uIesmnCS_DIX) ,Frtae isNm" ,LsNm" atae ,Ades drs" ,Ct" iy ,Sae tt" ,Zp i" ,Poeubr hnNme" )VLE ( AUS "

K SK L ~ J L ~J ~J J J S

ULRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

srQ ="PAECsoe ST" tSL UDT utmr E srQ =srQ &" Frtae tSL tSL isNm srQ =srQ &" LsNm tSL tSL , atae srQ =srQ &" Ades tSL tSL , drs srQ =srQ &" Ct tSL tSL , iy srQ =srQ &" Sae tSL tSL , tt srQ =srQ &" Zp tSL tSL , i =' &Rpae(xFrtTx,"" "')&"" " elc$ttis.et ', '" ' =' &Rpae(xLs.et "" "')&"" " elc$ttatTx, ', '" ' =' &Rpae(xAd.et "" "')&"" " elc$ttdrTx, ', '" ' =' &Rpae(xCt.et "" "')&"" " elc$ttiyTx, ', '" ' =' &tttt.et&"" " xSaeTx ' =' &tti.et&"" " xZpTx '

srQ =srQ &" Poeubr=' &srhn &"" tSL tSL , hnNme " tPoe ' srQ =srQ &"WEECsI ="&lgDil tSL tSL HR utD nIFed lwutmrSlceIe.et=ttis.et vCsoe.eetdtmTx xFrtTx PpltLsIe lwutmrSlceIe ouaeittm vCsoe.eetdtm EdI n f mbCdCmadet=srQ ojm.omnTx tSL mbCdEeue ojm.xct Stomtt Tu eFrSae re mlUdtIPors =Fle bnpaenrges as EdSb n u When we need to add a new record, a new, unique record ID must generated. In this particular sample application, the record ID is defined as a Long Integer in the database. The GetNextCustID function shown below uses the SQL MAX function to find the highest existing value for the CustID field, adds one to it, and returns that value to the caller. It should be noted that if the CustID field was defined as an Access AutoNumber field, the logic of this application would have to be modified accordingly. '---------------------------------------------------------------------------PiaeSbcdaeCik) rvt u mSv_lc( '---------------------------------------------------------------------------Dmsrhn i tPoe DmlgDil i nIFed DmsrQ i tSL A Srn s tig A Ln s og A Srn s tig

DmojeLsIe A LsIe i bNwittm s ittm

I NtVldtFrFed Te Ei Sb f o aiaeomils hn xt u srhn =ttraTx &ttrxTx &ttieTx tPoe xAe.et xPf.et xLn.et I mtMitoe="D"Te f sranMd AD hn lgDil =GtetutD) nIFed eNxCsI( srQ ="NETIT Csoe( CsI" tSL ISR NO utmr utD srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL
K SK L ~ J L ~J ~J J J S

,Frtae isNm" ,LsNm" atae ,Ades drs" ,Ct" iy ,Sae tt"


VLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &lgDil tSL tSL nIFed

,Zp i" ,Poeubr hnNme" )VLE ( AUS "

srQ =srQ &" ' &Rpae(xFrtTx,"" "')&"" tSL tSL , " elc$ttis.et ', '" ' srQ =srQ &" ' &Rpae(xLs.et "" "')&"" tSL tSL , " elc$ttatTx, ', '" ' srQ =srQ &" ' &Rpae(xAd.et "" "')&"" tSL tSL , " elc$ttdrTx, ', '" ' srQ =srQ &" ' &Rpae(xCt.et "" "')&"" tSL tSL , " elc$ttiyTx, ', '" ' srQ =srQ &" ' &tttt.et&"" tSL tSL , " xSaeTx ' srQ =srQ &" ' &tti.et&"" tSL tSL , " xZpTx ' srQ =srQ &" ' &srhn &"" tSL tSL , " tPoe ' srQ =srQ &"" tSL tSL ) StojeLsIe =lwutmrLsIesAd,,ttis.et ,"ut" e bNwittm vCsoe.ittm.d( xFrtTx, Css) PpltLsIe ojeLsIe ouaeittm bNwittm Wt ojeLsIe ih bNwittm .uIesmnCS_DIX =Ct(nIFed Sbtm(lgUTI_D) SrlgDil) .nueiil EsrVsbe EdWt n ih StlwutmrSlceIe =ojeLsIe e vCsoe.eetdtm bNwittm StojeLsIe =Ntig e bNwittm ohn Es le lgDil =Cn(vCsoe.eetdtmSbtm(lgUTI_D) nIFed LglwutmrSlceIe.uIesmnCS_DIX) srQ ="PAECsoe ST" tSL UDT utmr E srQ =srQ &" Frtae tSL tSL isNm srQ =srQ &" LsNm tSL tSL , atae srQ =srQ &" Ades tSL tSL , drs srQ =srQ &" Ct tSL tSL , iy srQ =srQ &" Sae tSL tSL , tt srQ =srQ &" Zp tSL tSL , i =' &Rpae(xFrtTx,"" "')&"" " elc$ttis.et ', '" ' =' &Rpae(xLs.et "" "')&"" " elc$ttatTx, ', '" ' =' &Rpae(xAd.et "" "')&"" " elc$ttdrTx, ', '" ' =' &Rpae(xCt.et "" "')&"" " elc$ttiyTx, ', '" ' =' &tttt.et&"" " xSaeTx ' =' &tti.et&"" " xZpTx '

srQ =srQ &" Poeubr=' &srhn &"" tSL tSL , hnNme " tPoe ' srQ =srQ &"WEECsI ="&lgDil tSL tSL HR utD nIFed lwutmrSlceIe.et=ttis.et vCsoe.eetdtmTx xFrtTx PpltLsIe lwutmrSlceIe ouaeittm vCsoe.eetdtm EdI n f mbCdCmadet=srQ ojm.omnTx tSL mbCdEeue ojm.xct Stomtt Tu eFrSae re mlUdtIPors =Fle bnpaenrges as EdSb n u For a delete action, after we have confirmed that the user truly wants to delete the record, we set the CommandText property of the Command object directly with the necessary SQL statement as shown below: mbCdCmadet="EEEFO Csoe WEECsI ="&lgutD ojm.omnTx DLT RM utmr HR utD nCsI The DELETE action query is then executed with the statement
K SK L ~ J L ~J ~J J J S NM LRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

mbCdEeue ojm.xct Logic is then executed to update the listview to remove the deleted record. '---------------------------------------------------------------------------PiaeSbcdeeeCik) rvt u mDlt_lc( '---------------------------------------------------------------------------DmsrisNm i tFrtae Dmsratae i tLsNm DmlgutD i nCsI A Srn s tig A Srn s tig A Ln s og

DmlgeSlne A Ln i nNweIdx s og I lwutmrSlceIe I NtigTe f vCsoe.eetdtm s ohn hn Mgo "oCsoe slce t dlt.,_ sBx N utmr eetd o eee" vEcaain _ bxlmto, "eee Dlt" Ei Sb xt u EdI n f Wt lwutmrSlceIe ih vCsoe.eetdtm srisNm =.et tFrtae Tx sratae=.uIesmnCS_ATIX tLsNm Sbtm(lgUTLS_D) lgutD=Cn(Sbtm(lgUTI_D) nCsI Lg.uIesmnCS_DIX) EdWt n ih I Mgo(Aeyusr ta yuwn t dlt Csoe ' _ f sBx"r o ue ht o at o eee utmr " &srisNm &""&sratae&"?,_ tFrtae tLsNm '" vYso+vQeto,_ beN busin "ofr Dlt" =vN Te Cnim eee) bo hn Ei Sb xt u EdI n f mbCdCmadet="EEEFO Csoe WEECsI ="&lgutD ojm.omnTx DLT RM utmr HR utD nCsI mbCdEeue ojm.xct Wt lwutmr ih vCsoe I .eetdtmIdx=.ittm.on Te f SlceIe.ne LsIesCut hn lgeSlne =.ittm.on -1 nNweIdx LsIesCut Es le lgeSlne =.eetdtmIdx nNweIdx SlceIe.ne EdI n f .ittm.eoe.eetdtmIdx LsIesRmv SlceIe.ne I .ittm.on >0Te f LsIesCut hn St.eetdtm=.ittm(nNweIdx e SlceIe LsIeslgeSlne) lwutmrIeCik.eetdtm vCsoe_tmlc SlceIe Es le CerureCnrl laCrRcotos EdI n f EdWt n ih EdSb n u
K SK L ~ J L ~J ~J J J S NNLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

When the program ends, the DisconnectFromDB sub is called to clean up the database objects. The Command object variable mobjCmd is set to Nothing. The ADO Connection is then closed by issuing the Close method on the Connection object variable mobjConn, and then that object is set to Nothing as well. Note: It was not necessary to "clean up" the Recordset object variable mobjRst, because it was set to Nothing at the end of each Sub in which it was used. '---------------------------------------------------------------------------PiaeSbDsoncFoD( rvt u icnetrmB) '---------------------------------------------------------------------------StmbCd=Ntig e ojm ohn mbCn.ls ojonCoe StmbCn =Ntig e ojon ohn EdSb n u Using the ListView Control In this section of the article, code related to the use of the ListView will be explained. To incorporate the ListView control into your project, you must add the Microsoft Windows Common Controls 6.0 component group to your toolbox (via Project -> Components). This is the same group that includes the ImageList, Toolbar, StatusBar, etc. In this project, a ListView control named lvwCustomer and an ImageList control named imlLVIcons were added to the form. (If you want to use icons with your ListView, you must store those icons in an ImageList control that will be tied to the ListView control.) An icon representing "customers" was added to the imlLVIcons ImageList; this image was given a Key property of "Custs". The following properties of the ListView were set at design time:

Property

Value

Notes

View

3 lvwReport

The ListView is used prominently in the MS-Windows interface. It is used to display the lists of files and folders in the Windows Explorer and My Computer applications. In those applications, you can go to the View menu and specify Large Icons, Small Icons, List, or Details, and the appearance of the file list is modified accordingly. With the VB ListView control, the 0-lvwIcon (the default), 1-lvwSmallIcon, 2-lvwList, and 3lvwReport settings for the View property correspond respectively to the Windows Explorer / My Computer View menu options listed above. Setting the ListView View property to 3-lvwReport enables the display of data in a columnar, grid-like fashion.

LabelEdit

1 - lvwManual

In a Windows Explorer or My Computer ListView, you know that you can rename a file by clicking once on its text label, then clicking it again. With the VB ListView control, the editing of the text label is possible when the LabelEdit property is set to 0-lvwAutomatic (which is the default). To prevent the user from modifying the data in the text label (which is the first column of the list when using the 3-lvwReport View), the LabelEdit property must be set to 1-lvwManual.

FullRowSelect

True

This is a Boolean property that is applicable only when View is set to 3NO LRP

K SK L ~ J L ~J ~J J J S

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

lvwReport. If False (the default), only the first column will be highlighted when a row is selected. If True, the entire row will be highlighted when selected.

GridLines

True

This is a Boolean property that is applicable only when View is set to 3lvwReport. If True, grid lines will border the cells of the ListView. The default is False.

On the Property Pages, Image Lists tab, the "Small" Icon Image List was set to imlLVIcons (the ImageList that was added to the form). In the Form_Load event, a call is made to the programmer-defined Sub "SetupCustLVCols". Here, we set up the columns for the ListView by using the Add method of the ListView's ColumnHeaders collection. The arguments for the Add method, all optional, are: index, key, text, width, alignment, icon. In the code below, only the text and the width arguments are specified. The text argument specifies the text that will appears in the column header. A common technique to specify the width is to use a percentage of the ListView as a whole. In the code below, the First Name will take up 15% of the ListView's width; the Last Name will take up 12%, and so on. In order to prevent a horizontal scroll bar from appearing at the bottom of the ListView, keep the total width under 100% (in the code below, the percentages add up to 98%). (If you want to display many columns, or certain columns must be particularly wide, the total percentage can certainly exceed 100%, in which case a horizontal scroll bar will automatically appear at the bottom of the ListView, and the user will have to scroll to see one or more columns.) Note that you may specify 0 for the column width, in which case you create a "hidden" column, useful for storing data that the user need not see (in this case, the "ID" column). The alignment property is not specified for any of the columns in the code below, so by default, all of the columns will be left-aligned. The other alignment options are centered or right-aligned. The alignment argument for left, center, and right are specified with the constants lvwColumnLeft, lvwColumnCenter, and lvwColumnRight, respectively. The code for this Sub is as follows: '---------------------------------------------------------------------------PiaeSbStputVos) rvt u euCsLCl( '---------------------------------------------------------------------------Wt lwutmr ih vCsoe .ounedr.la ClmHaesCer .ounedr.d ,,"is Nm" .it *01 ClmHaesAd Frt ae, Wdh .5 .ounedr.d ,,"atNm" .it *01 ClmHaesAd Ls ae, Wdh .2 .ounedr.d ,,"drs" .it *02 ClmHaesAd Ades, Wdh . .ounedr.d ,,"iy,.it *01 ClmHaesAd Ct" Wdh .5 .ounedr.d ,,"t,.it *00 ClmHaesAd S" Wdh .6 .ounedr.d ,,"i" .it *01 ClmHaesAd Zp, Wdh . .ounedr.d ,,"hn #,.it *02 ClmHaesAd Poe " Wdh . .ounedr.d ,,"D,0 ClmHaesAd I" EdWt n ih EdSb n u Also in the Form_Load event, following the call to "SetupCustLVCols" is the call to the "LoadCustomerListView" Sub. We looked at this Sub earlier to examine the ADO/database aspects of the code; now we will look at it to examine the ListView aspects of the code. A local ListItem object, objCurrLI, is declared. ListItem objects represent the entries of the ListView; they are the components of the ListView's ListItems collection.

K SK L ~ J L ~J ~J J J S

NPLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

After the recordset has been created, we first use the Clear method to remove all existing ListItem objects from the ListView (this step is technically not needed in the case of this particular application, but it is good practice to do this there could be situations where you need to reload a ListView, and failure to clear the existing items will result in extraneous or duplicate items in the list). As we loop through the Recordset, for each record we create a new ListItem object by invoking the Add method of the ListItems collection, setting the reference to the new ListItem to the objCurrLI variable. The arguments for the Add method, all optional, are: index, key, text, icon, smallicon. We are using only the text and the smallicon arguments. The text argument sets the Text property of the ListView; it is the text that will appear in the first column of the ListView (in this case, it is the FirstName field from the recordset). The smallicon argument refers to the image that will appear to the left of each ListItem; here we specify "Custs", which is the Key of the desired image in the imlLVIcons ImageList control (which we tied to this ListView control). The remaining fields of the recordset are assigned to the corresponding SubItems entries of the current ListItem. Whenever you add more than one ColumnHeader object, you create corresponding SubItem elements that are associated with each ListItem. The SubItems collection is a string array of data associated with a ListItem. ColumnHeaders and SubItems are "1-based" collections however, the upper bound of the SubItems is always one greater than the upper bound of the ColumnHeaders. This is because ColumnHeaders(1) corresponds to the ListItem's Text property; ColumnHeaders(2) through ColumnHeaders(n) correspond to the ListItem's SubItems(1) through SubItems(n 1). Note that constants are used for the SubItem indexes (you could alternatively just use hard-coded numbers to refer to the indexes). These constants were defined at the form-level: 'Csoe L SbtmIdxs.. utmr V uIe nee . PiaeCntmnCS_ATIX rvt os lgUTLS_D PiaeCntmnCS_DRIX rvt os lgUTAD_D PiaeCntmnCS_IYIX rvt os lgUTCT_D PiaeCntmnCS_TIX rvt os lgUTS_D PiaeCntmnCS_I_D rvt os lgUTZPIX PiaeCntmnCS_HN_D rvt os lgUTPOEIX PiaeCntmnCS_DIX rvt os lgUTI_D A Ln =1 s og A Ln =2 s og A Ln =3 s og A Ln =4 s og A Ln =5 s og A Ln =6 s og A Ln =7 s og

After the loop has completed, we then check the Count property of the ListItems collection. As long as at least one record was loaded, we set the SelectedItem property of the ListView to the first ListItem. The SelectedItem property of the ListView is a reference to the ListItem that is currently selected. (Normally, the SelectedItem property is set when the user clicks on a ListItem.) We then call the ListView's ItemClick event (lvwCustomer_ItemClick). The ItemClick event expects a ListItem argument, so we pass it the selected item that we just set. (Normally, the ItemClick event is fired when the user clicks on a ListItem.) We will explore the code for the lvwCustomer_ItemClick event shortly. The code for "LoadCustomerListView" is shown below, with the ListView-related code in bold: '---------------------------------------------------------------------------PiaeSbLaCsoeLsVe( rvt u odutmritiw) '---------------------------------------------------------------------------DmsrQ i tSL DmojurI i bCrL Dmsri i tZp Dmsrhn i tPoe A Srn s tig A LsIe s ittm A Srn s tig A Srn s tig

srQ ="EETFrtae _ tSL SLC isNm" &" &" ,LsNm"_ atae ,Ades _ drs"
NQ LRP

K SK L ~ J L ~J ~J J J S

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

&" &" &" &" &"

,Ct"_ iy ,Sae _ tt" ,Zp _ i" ,Poeubr _ hnNme" ,CsI"_ utD

&" FO Csoe "_ RM utmr &"ODRB LsNm"_ RE Y atae &" ,Frtae isNm"

mbCdCmadet=srQ ojm.omnTx tSL StmbRt=mbCdEeue e ojs ojm.xct lwutmrLsIesCer vCsoe.ittm.la Wt mbRt ih ojs D Utl.O o ni EF srhn =!hnNme &" tPoe Poeubr " I Lnsrhn)>0Te f e(tPoe hn srhn =""&Lf$srhn,3 &" "_ tPoe ( et(tPoe ) ) &Md(tPoe 4 3 &""_ i$srhn, , ) &Rgt(tPoe 4 ih$srhn, ) EdI n f StojurI=lwutmrLsIesAd,,!isNm &",,"ut" e bCrL vCsoe.ittm.d( Frtae " Css) ojurISbtm(lgUTLS_D)=!atae&" bCrL.uIesmnCS_ATIX LsNm " ojurISbtm(lgUTAD_D)=!drs &" bCrL.uIesmnCS_DRIX Ades " ojurISbtm(lgUTCT_D)=!iy&" bCrL.uIesmnCS_IYIX Ct " ojurISbtm(lgUTS_D)=!tt &" bCrL.uIesmnCS_TIX Sae " ojurISbtm(lgUTZPIX =!i &" bCrL.uIesmnCS_I_D) Zp " ojurISbtm(lgUTPOEIX =srhn bCrL.uIesmnCS_HN_D) tPoe ojurISbtm(lgUTI_D)=Ct(CsI) bCrL.uIesmnCS_DIX Sr!utD .oeet MvNx Lo op EdWt n ih Wt lwutmr ih vCsoe I .ittm.on >0Te f LsIesCut hn St.eetdtm=.ittm() e SlceIe LsIes1 lwutmrIeCik.eetdtm vCsoe_tmlc SlceIe EdI n f EdWt n ih StojurI=Ntig e bCrL ohn StmbRt=Ntig e ojs ohn EdSb n u The ListView's ItemClick event is fired when the user clicks on a ListItem in the ListView. VB passes an argument called Item to the event, which refers to the ListItem that was clicked. In the lvwCustomer_ItemClick event below, we populate the textboxes in the "Current Record" frame of the form with the data from the currently selected ListItem. '--------------------------------------------------------------------------- K SK L ~ J L ~J ~J J J S NRLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

PiaeSblwutmrIeCikBVlIe A MCmtLbLsIe) rvt u vCsoe_tmlc(ya tm s Socli.ittm '---------------------------------------------------------------------------glPpltn =Tu bnouaig re Wt Ie ih tm ttis.et=.et xFrtTx Tx ttatTx =.uIesmnCS_ATIX xLs.et Sbtm(lgUTLS_D) ttdrTx =.uIesmnCS_DRIX xAd.et Sbtm(lgUTAD_D) ttiyTx =.uIesmnCS_IYIX xCt.et Sbtm(lgUTCT_D) tttt.et=.uIesmnCS_TIX xSaeTx Sbtm(lgUTS_D) tti.et=.uIesmnCS_I_D) xZpTx Sbtm(lgUTZPIX I .uIesmnCS_HN_D)=" Te f Sbtm(lgUTPOEIX " hn ttraTx =" xAe.et " ttrxTx =" xPf.et " ttieTx =" xLn.et " Es le ttraTx =Md(Sbtm(lgUTPOEIX,2 3 xAe.et i$.uIesmnCS_HN_D) , ) ttrxTx =Md(Sbtm(lgUTPOEIX,7 3 xPf.et i$.uIesmnCS_HN_D) , ) ttieTx =Rgt(Sbtm(lgUTPOEIX,4 xLn.et ih$.uIesmnCS_HN_D) ) EdI n f EdWt n ih glPpltn =Fle bnouaig as EdSb n u The ListView's ColumnClick event is fired when the user clicks on one of the ListView's column headers. VB passes an argument called ColumnHeader to the event, which refers to the column header that was clicked. What we want to do is sort the ListView by the column that was clicked. The ListView control has three properties related to sorting: Sorted is a Boolean indicating whether or not the ListView is currently sorted. SortKey is an integer representing the column currently sorted. Zero specifies that the ListView is sorted on the value of the Text property (i.e., the first column). A number from 1 to the number of SubItems specifies that the ListView is sorted on the value of that SubItem. The SubItemIndex property of the ColumnHeader object returns the appropriate value. SortOrder is a numeric value indicating whether the sort is ascending or descending. The values can be specified with the constants lvwAscending or lvwDescending. The first part of the code in the lvwCustomer_ColumnClick event checks to see if the user clicked on the column that the ListView is currently sorted on. If so, it toggles the ascending / descending value. Otherwise, it sorts the ListView on the clicked column in ascending order. The second part of the code makes sure that, if an item was selected prior to the sort, it is still visible after the sort. The EnsureVisible method of the ListItem object checks that the ListItem is currently viewable in the ListView if not, it automatically scrolls the ListView to make it viewable. '-----------------------------------------------------------------------PiaeSblwutmrClmCikBVlClmHae A Socli.ounedr rvt u vCsoe_ounlc(ya ounedr s CmtLbClmHae) '-----------------------------------------------------------------------'sr telsve o teclm cikd ot h itiw n h oun lce
K SK L ~ J L ~J ~J J J S NSLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Wt lwutmr ih vCsoe I (Sre)Ad(ounedrSbtmne =.ote)Te f .otd n ClmHae.uIeIdx SrKy hn I .otre =lwsedn Te f SrOdr vAcnig hn .otre =lwecnig SrOdr vDsedn Es le .otre =lwsedn SrOdr vAcnig EdI n f Es le .otd=Tu Sre re .ote =ClmHae.uIeIdx SrKy ounedrSbtmne .otre =lwsedn SrOdr vAcnig EdI n f .ers Rfeh EdWt n ih 'I a ie wsslce pirt tesr, f n tm a eetd ro o h ot 'mk sr i i silvsbenwta tesr i dn. ae ue t s tl iil o ht h ot s oe I NtlwutmrSlceIe I NtigTe f o vCsoe.eetdtm s ohn hn lwutmrSlceIe.nueiil vCsoe.eetdtmEsrVsbe EdI n f EdSb n u Next, we will look at the ListView's role in cmdSave_Click event. We looked at this Sub earlier to examine the ADO/database aspects of the code; now we will look at it to examine the ListView aspects of the code. A ListItem object variable, objNewListItem, is declared at the local level. This will be used on the "ADD" side (i.e., if we are saving a newly added record). On the "ADD" side, after we have set up the SQL to do an INSERT, we use the Add method of the ListItems collection to add a new ListItem. The reference to the new ListItem is assigned to the objNewListItem variable. Note that the first name that has been entered into the txtFirst textbox is used for the Text property of the newly added item. The next statement calls the programmer-defined Sub PopulateListItem, passing it the newly added ListItem as an argument (the code for PopulateListItem will be shown a little later below, but all it does is assign the values of the textboxes used in the add or update to the corresponding SubItems of the ListItem object passed in to the Sub). Following this, the new Customer ID (that was established when GetNextCustID was called) is assigned to the corresponding SubItem of the new ListItem. The EnsureVisible method is invoked to ensure that the user can see the newly added item. The SelectedItem property is then set to reference the newly added item. To clean things up, the objNewListItem variable is then set to Nothing. On the "UPDATE" side, our job is to modify the SubItem values of the currently selected item to reflect the user's changes. Here, we get the value for the lngIDField variable from the "hidden" Cust ID column of the currently selected ListItem of the ListView. This variable is then used in the building of the UPDATE SQL statement. We then set the Text property of the currently selected item to the first name entered in the txtFirst textbox, and then we call the PopulateListItem Sub, passing the the currently selected ListItem. The code for the "cmdSave_Click" event procedure is shown below, with the ListView-related code in bold: '---------------------------------------------------------------------------PiaeSbcdaeCik) rvt u mSv_lc( '---------------------------------------------------------------------------Dmsrhn i tPoe DmlgDil i nIFed A Srn s tig A Ln s og
NTLRP

DmojeLsIe A LsIe i bNwittm s ittm

K SK L ~ J L ~J ~J J J S

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

DmsrQ i tSL

A Srn s tig

I NtVldtFrFed Te Ei Sb f o aiaeomils hn xt u srhn =ttraTx &ttrxTx &ttieTx tPoe xAe.et xPf.et xLn.et I mtMitoe="D"Te f sranMd AD hn lgDil =GtetutD) nIFed eNxCsI( srQ ="NETIT Csoe( CsI" tSL ISR NO utmr utD srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &" tSL tSL srQ =srQ &lgDil tSL tSL nIFed srQ =srQ &" ' &Rpae(xFrtTx,"" "')&"" tSL tSL , " elc$ttis.et ', '" ' srQ =srQ &" ' &Rpae(xLs.et "" "')&"" tSL tSL , " elc$ttatTx, ', '" ' srQ =srQ &" ' &Rpae(xAd.et "" "')&"" tSL tSL , " elc$ttdrTx, ', '" ' srQ =srQ &" ' &Rpae(xCt.et "" "')&"" tSL tSL , " elc$ttiyTx, ', '" ' srQ =srQ &" ' &tttt.et&"" tSL tSL , " xSaeTx ' srQ =srQ &" ' &tti.et&"" tSL tSL , " xZpTx ' srQ =srQ &" ' &srhn &"" tSL tSL , " tPoe ' srQ =srQ &"" tSL tSL ) StojeLsIe =lwutmrLsIesAd,,ttis.et ,Css) e bNwittm vCsoe.ittm.d( xFrtTx, ut" PpltLsIe ojeLsIe ouaeittm bNwittm Wt ojeLsIe ih bNwittm .uIesmnCS_DIX =Ct(nIFed Sbtm(lgUTI_D) SrlgDil) .nueiil EsrVsbe EdWt n ih StlwutmrSlceIe =ojeLsIe e vCsoe.eetdtm bNwittm StojeLsIe =Ntig e bNwittm ohn Es le lgDil =Cn(vCsoe.eetdtmSbtm(lgUTI_D) nIFed LglwutmrSlceIe.uIesmnCS_DIX) srQ ="PAECsoe ST" tSL UDT utmr E srQ =srQ &" Frtae tSL tSL isNm srQ =srQ &" LsNm tSL tSL , atae srQ =srQ &" Ades tSL tSL , drs srQ =srQ &" Ct tSL tSL , iy srQ =srQ &" Sae tSL tSL , tt srQ =srQ &" Zp tSL tSL , i =' &Rpae(xFrtTx,"" '" &"" " elc$ttis.et ', ') ' =' &Rpae(xLs.et "" '" &"" " elc$ttatTx, ', ') ' =' &Rpae(xAd.et "" '" &"" " elc$ttdrTx, ', ') ' =' &Rpae(xCt.et "" '" &"" " elc$ttiyTx, ', ') ' =' &tttt.et&"" " xSaeTx ' =' &tti.et&"" " xZpTx ' ,Frtae isNm" ,LsNm" atae ,Ades drs" ,Ct" iy ,Sae tt" ,Zp i" ,Poeubr hnNme" )VLE ( AUS "

srQ =srQ &" Poeubr=' &srhn &"" tSL tSL , hnNme " tPoe ' srQ =srQ &"WEECsI ="&lgDil tSL tSL HR utD nIFed lwutmrSlceIe.et=ttis.et vCsoe.eetdtmTx xFrtTx PpltLsIe lwutmrSlceIe ouaeittm vCsoe.eetdtm
K SK L ~ J L ~J ~J J J S NULRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

EdI n f mbCdCmadet=srQ ojm.omnTx tSL mbCdEeue ojm.xct Stomtt Tu eFrSae re mlUdtIPors =Fle bnpaenrges as EdSb n u The code for the programmer-defined Sub "PopulateListItem" (discussed above) is shown below: '---------------------------------------------------------------------------PiaeSbPpltLsIe(ojittmA LsIe) rvt u ouaeittmpbLsIe s ittm '---------------------------------------------------------------------------Wt pbLsIe ih ojittm .uIesmnCS_ATIX =ttatTx Sbtm(lgUTLS_D) xLs.et .uIesmnCS_DRIX =ttdrTx Sbtm(lgUTAD_D) xAd.et .uIesmnCS_IYIX =ttiyTx Sbtm(lgUTCT_D) xCt.et .uIesmnCS_TIX =tttt.et Sbtm(lgUTS_D) xSaeTx .uIesmnCS_I_D)=tti.et Sbtm(lgUTZPIX xZpTx .uIesmnCS_HN_D)_ Sbtm(lgUTPOEIX =IfttraTx =",_ I(xAe.et " ",_ " ""&ttraTx &" "&ttrxTx &""&ttieTx) ( xAe.et ) xPf.et xLn.et EdWt n ih EdSb n u The last bit of ListView-related code we will look at is in the cmdDelete_Click event procedure. In the first section of highlighted code, we use the SelectedItem to get the first and last name of the customer to be deleted so that we can present the message "Are you sure that you want to delete Customer so-and-so?"; we also get the Cust ID for use in building the SQL string. Provided that the user goes ahead with the delete, we must refresh the ListView accordingly: we are going to remove the currently selected item, and we also want to establish a "new" selected item (we will store the index of the new selected item in the variable lngNewSelIndex). We first test to see if the item to be deleted is the last item of the ListView if it is, then the "new" selected item's index will be one less than currently selected item's index (for example, if you have five items and you delete the fifth one, the "new" last item will be the fourth one) otherwise the "new" selected item's index will be the same as the currently selected item's index (for example, if you have five items and you delete the third one, the item that was previously fourth will now be third). The selected item is then removed with the Remove method of the ListItems collection. Provided that we did not delete the very last record of the table, we set the "new" selected item (using the value of the lngNewSelIndex variable) and then call the lvwCustomer_ItemClick event procedure, passing it that new item which will cause the textboxes to be populated with the data from the newly selected item. '---------------------------------------------------------------------------PiaeSbcdeeeCik) rvt u mDlt_lc( '---------------------------------------------------------------------------DmsrisNm i tFrtae Dmsratae i tLsNm A Srn s tig A Srn s tig
NVLRP

K SK L ~ J L ~J ~J J J S

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

DmlgutD i nCsI

A Ln s og

DmlgeSlne A Ln i nNweIdx s og I lwutmrSlceIe I NtigTe f vCsoe.eetdtm s ohn hn Mgo "oCsoe slce t dlt.,_ sBx N utmr eetd o eee" vEcaain _ bxlmto, "eee Dlt" Ei Sb xt u EdI n f Wt lwutmrSlceIe ih vCsoe.eetdtm srisNm =.et tFrtae Tx sratae=.uIesmnCS_ATIX tLsNm Sbtm(lgUTLS_D) lgutD=Cn(Sbtm(lgUTI_D) nCsI Lg.uIesmnCS_DIX) EdWt n ih I Mgo(Aeyusr ta yuwn t dlt Csoe ' _ f sBx"r o ue ht o at o eee utmr " &srisNm &""&sratae&"?,_ tFrtae tLsNm '" vYso+vQeto,_ beN busin "ofr Dlt" =vN Te Cnim eee) bo hn Ei Sb xt u EdI n f mbCdCmadet="EEEFO Csoe WEECsI ="&lgutD ojm.omnTx DLT RM utmr HR utD nCsI mbCdEeue ojm.xct Wt lwutmr ih vCsoe I .eetdtmIdx=.ittm.on Te f SlceIe.ne LsIesCut hn lgeSlne =.ittm.on -1 nNweIdx LsIesCut Es le lgeSlne =.eetdtmIdx nNweIdx SlceIe.ne EdI n f .ittm.eoe.eetdtmIdx LsIesRmv SlceIe.ne I .ittm.on >0Te f LsIesCut hn St.eetdtm=.ittm(nNweIdx e SlceIe LsIeslgeSlne) lwutmrIeCik.eetdtm vCsoe_tmlc SlceIe Es le CerureCnrl laCrRcotos EdI n f EdWt n ih EdSb n u Download the project files for this sample application here. Post to Facebook Post to Twitter Add to LinkedIn Post to Delicious Post to Digg Post on Google Buzz
K SK L ~ J L ~J ~J J J S O LRP M

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Similar links
Error handling in Visual Basic Understanding Repetition (Loops in VB) VB String Array Functions - Split, Join, Filter VB6 Downloads Convert C Strings to VB Strings Error Handling In Visual Basic Understanding Subroutines and Functions in VB Assignments and Expressions In VB A little more advanced Hello World program Working with Menus in VB6

If you enjoyed this post, subscribe for updates (it's free) Email Address... Subscribe

How to make datagrid editable.

Fri, 12/16/2011 - 06:40 Ahsan Sharif (not verified)

how to make the data grid editable like enter new data from the data grid and stores it into the database access. reply

How to make datagrid editable.

Fri, 12/16/2011 - 06:40 Ahsan Sharif (not verified)

how to make the datagrid editable like enter new data from the datagrid and stores it into the database access. reply

show listbox when an item is added in the textbox.


K SK L ~ J L ~J ~J J J S

Fri, 12/16/2011 - 06:30 Ahsan Sharif (not verified) O NLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

How to show a list box when an item is written in the textbox by a user and that item is already present in that list box, it is like a google suggestion or like an intellisense. Kindly reply me as soon as u can i want to do my project complte quickly. Thanks reply

plz give coding so that i cn


plz give coding so that i cn access data base by command button sSERACH BY NAME OR ACCOUNT NO. reply

Wed, 11/16/2011 - 00:20 arvind purohit (not verified)

ab8 table

Thu, 10/27/2011 - 18:42 Gaurav1988 (not verified)

how to make search for the names in above table. whats the programme for this reply

Excellent Work & plz send me sale form

Wed, 10/26/2011 - 01:05 daminasi (not verified)

hi, I'm beginner in vb6, plz help me.i make stock control project in my exam,but i have a problem.Ur customer form is best.because if u can send list view or DBgrid, amount ,quantity and discount with made sale form like customer form. my English poor.sorry. my mail: moneydami@ymail.com. reply

i'm just a beginner in vb6.

Mon, 10/10/2011 - 00:15 darkangel (not verified)

i'm just a beginner in vb6. pls. help me in database connection... i will br so greatefull... D.A reply

trouble shoot this error,,please,,


I had one probleme to learn about VB 6, here are the list of the code, how to make good trouble shoot yellow line in VB = (==>) -------------------------------------------------------------run time error '91' object variable or with block variable not set" Private Sub cbopro_Click(Area As Integer)
K SK L ~ J L ~J ~J J J S

Fri, 08/05/2011 - 06:40 Mr. dick (not verified)

O LRP O

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

=================================== Private Sub cbopro_Click(Area As Integer) rstbproduk.Requery ==> If Area = 2 Then Call lCarikdproduk End Sub Private Sub lCarikdproduk() If Trim(cbopro.Text) = "" Then Exit Sub Set rsDetail = New ADODB.Recordset With rsDetail sql = "SELECT * from tbproduk WHERE kdproduk = '" & cbopro.Text & "'" .Open sql, conn, adOpenStatic, adLockReadOnly If .RecordCount = 0 Then lblkdproduk.Caption = "" Else 'cnmproduk = !nmproduk lblkdproduk.Caption = !nmproduk End If End With End Sub I need your help soon,,, thanks a lot for your time,, reply

how to search a data from database

Mon, 06/27/2011 - 00:51 umeshHARDE (not verified)

I am just beginer in vb6. I want to design a form for searching data of book with Accession No. If anyone send me source code of the program. I really will be grateful. Thanks umesh reply

I want to create AIRLINES

Tue, 06/07/2011 - 07:04 Anonymous (not verified)

I want to create AIRLINES project using my own knowledge. If you do any help for me reply

Hello Sir, Hoe generate


Hello Sir,

Wed, 06/01/2011 - 04:58 Deepak K N (not verified)

Hoe generate dynamic report(Using any Reporting Tool) so that client can modify it thanks

K SK L ~ J L ~J ~J J J S

O PLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

reply

Reports
Dear Sir,

Wed, 06/01/2011 - 04:56 Deepak K N (not verified)

How to generate dynamic reports (using any Reporting Tool) so that customer can modify it. Please guide me on this. Thanks reply

I want to learn ado shape


Dear Sir,

Tue, 04/19/2011 - 17:03 Anonymous (not verified)

I want to learn ado shape .How to add , delete,modify record in ado shape? Thanks reply

listview problem in deleting items

Fri, 03/25/2011 - 12:42 humaira wagan

when we are selecting any record from listview and pressing delete button it doesn't delete the selected record from the database,it deletes the first record present in the database not the selected...plz help it out thanks reply

listview problem in deleting items


here is the code..hope it will help.. lvw - listview name cDel - name of commandbutton. If lvw.ListItems.Count <> 0 Then lvw.Tag = lvw.ListItems(lvw.SelectedItem.Index) End If Private Sub cDel_Click() If lvw.Tag <> "" Then

Mon, 11/21/2011 - 23:35 PalomoSoft

If MsgBox("Are you sure you want to DELETE this record?", vbExclamation + vbYesNo, "Delete Record") = vbYes Then con.Execute "Delete from tblcourse where cId = " & Int(lvw.Tag) & "" MsgBox "Data Successfully Deleted.", vbInformation, "Delete" Call Lvw_Loader();lvw.tag="" Else: lvw.Tag = "" End If
K SK L ~ J L ~J ~J J J S O LRP Q

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Else: MsgBox "NO selected record to be Deleted.", vbExclamation, "Delete Record" End If End Sub reply

error while cancelling the add person


i love your code very good ..but there is a problem i ereased all the contacts in the list view and when i add person and whant to cancel i get error ------------------------run time error 91 object variable or with block variable not set -----------------------any solution?? reply

Sun, 01/30/2011 - 10:05 arik (not verified)

the samething
i get the same error to.. somebody can help us? reply

Mon, 01/31/2011 - 00:48 David27 (not verified)

One solution found!


with the following one: '----------------------------------------------------------------------------Private Sub lvwCustomer_ItemClick(ByVal Item As MSComctlLib.ListItem) '----------------------------------------------------------------------------gblnPopulating = True If Not Item Is Nothing Then With Item txtFirst.Text = .Text txtLast.Text = .SubItems(mlngCUST_LAST_IDX) txtAddr.Text = .SubItems(mlngCUST_ADDR_IDX) txtCity.Text = .SubItems(mlngCUST_CITY_IDX) txtState.Text = .SubItems(mlngCUST_ST_IDX) txtZip.Text = .SubItems(mlngCUST_ZIP_IDX) If .SubItems(mlngCUST_PHONE_IDX) = "" Then txtArea.Text = "" txtPrfx.Text = "" txtLine.Text = ""
K SK L ~ J L ~J ~J J J S

Fri, 02/18/2011 - 12:28 C hrisGT7

Yeap! Same error to me also... The problem is at the Private Sub lvwCustomer_ItemClick. Replace the sub

O RLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Else txtArea.Text = Mid$(.SubItems(mlngCUST_PHONE_IDX), 2, 3) txtPrfx.Text = Mid$(.SubItems(mlngCUST_PHONE_IDX), 7, 3) txtLine.Text = Right$(.SubItems(mlngCUST_PHONE_IDX), 4) End If End With End If gblnPopulating = False End Sub It works perfectly now. The code was trying to display the data of the item clicked! But all the records were deleted so no display data was found. The If statement solved the problem! reply

progressbar loading DB
Hello everyone i need help

Fri, 07/08/2011 - 17:46 jamesfarhant (not verified)

i made a programm with database access using listview and a progressbar that will count the records and display them in the progressbar and its not working. this is the code. Option Explicit Public Cn As ADODB.Connection Public RS As ADODB.Recordset Private Sub Form_Load() Set RS = Cn.Execute("select * from tblAddresses ") While Not RS.EOF Set itm = frmMain.lvwAddress.ListItems.Add(, , RS!FirstName) RS.MoveNext pbr.Value = pbr.Value + 1 Wend frmMain.Show End Sub reply

DoEvents

Tue, 07/26/2011 - 10:38 Anonymous (not verified)

Under the line "pbr.Value = pbr.Value + 1" add the following command: DoEvents Of course this command will slow very much the loading proccess but it is very fancy to see a progress bar and helps the user to check if everything is OK. I believe this command is the missing part of your code.
K SK L ~ J L ~J ~J J J S O SLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

ChrisGT7 reply

thank you now i have another


thank you now i have another question

Sun, 02/20/2011 - 12:49 Arik (not verified)

i created another form in the same project as this customer listview. now how can i show the people from this form (listview) in my other form using combo box? i just want to display this customer list in a nother form and to add them their from the list and the person that i choose to add. thanks for advanced reply

Questions...

Sun, 02/20/2011 - 14:47 C hrisGT7

If I understand right, you have one combo box in your new form and this combo should be filled with all the first names of costumers? So you can choose from this combo the customer and display his details to another combos or text boxes? Or every time you click on a customer from the list, the combo box will be filled with all the details of the selected costumer? Looking forward for your explainations in order to help you. reply

combobox
hi exactly what you said before this: ---------------------

Mon, 02/28/2011 - 13:19 Arik (not verified)

"you have one combo box in your new form and this combo should be filled with all the first names of costumers? So you can choose from this combo the customer and display his details to another combos or text boxes?" i want to display the detail of the customers in the text box. reply

Arik
text
K SK L ~ J L ~J ~J J J S

Tue, 03/01/2011 - 04:51 Arik

i want to show the customers in another form using combobox and displaying the data in the

O TLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

reply

Done!

Tue, 03/01/2011 - 16:04 C hrisGT7

Let's say your new form is Form1, the combo for customers Combo1 and a control array of 5 text boxes to display in each one all the reamining details of the chosen customer from the combo box. Change the Index property of each text box to: 2, 3, 4, 5 and 6. Here are the steps of the code in your new form: Private Sub Form_Load() For i = 1 To frmCustMaint.lvwCustomer.ListItems.Count Combo1.AddItem frmCustMaint.lvwCustomer.ListItems(i) & " " & frmCustMaint.lvwCustomer.ListItems(i).SubItems(1) Next Combo1.Text = Combo1.List(0) End Sub Private Sub Combo1_Click() For i = 2 To 6 Text1(i).Text = frmCustMaint.lvwCustomer.ListItems(Combo1.ListIndex + 1).SubItems(i) Next End Sub If you delete a customer while your new form is open, your combo will not be updated and when you choose the deleted customer from it there will be a run-time error. You have to close your form and open it again to avoid the run-time error. Or you have to copy the code for filling the combo box in the code of the delete button. For anything else, please ask me. I hope this sample will satisfy you! reply

Combobox
hey ChrisGT7 im kind of new in vb 6 first of all second

Wed, 03/02/2011 - 00:44 Arik

it dosnt work and it dosnt even give me an error or something else ill try to make it simple that you can help me.i know im doing something wrong this is the code of my first form(forget the customers form for now) --------------------------------------------------------------------------------------------Option Explicit Private lBegin As Long Dim Columns As Long Dim i As Long Private fFreeze As Boolean Private Sub abc_Click()
K SK L ~ J L ~J ~J J J S O ULRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Form4414.Show 1 End Sub Private Sub cmdAdd_Click() frmNew.Show 1 End Sub Private Sub cmdDelete_Click() Dim strFirstName As String If Me.ListView.ListItems.Count = 0 Then MsgBox "", vbInformation, "" Exit Sub End If If MsgBox("DELTE?", vbYesNo, " ") = vbYes Then Call dbConnect conn.Execute "Delete * from tbl_info where id_info=" & Val(Me.ListView.SelectedItem.Text) & "" conn.Close Set conn = Nothing Me.ListView.ListItems.Remove (Me.ListView.SelectedItem.Index) MsgBox "", vbInformation, "" Else cancel = True End If End Sub Private Sub cmdEdit_Click() If Me.ListView.ListItems.Count = 0 Then MsgBox "", vbInformation, "" Exit Sub End If frmEdit.Show 1 End Sub Private Sub cmdRefresh_Click() Text1.Text = "" Call loadRecords Form11.Enabled = True End Sub Private Sub cmdSearch_Click() End Sub Private Sub Form_Load() fFreeze = True Me.MousePointer = vbHourglass

K SK L ~ J L ~J ~J J J S

O VLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Label8.Caption = " " & FormatDateTime(Now, vbLongDate) Call loadRecords With ListView Columns = .ColumnHeaders.Count For i = 1 To Columns .ColumnHeaders(i).Position = Columns - i + 1 Next End With Me.MousePointer = vbDefault End Sub Private Sub Form_Unload(cancel As Integer) Dim Form As Form For Each Form In Forms Unload Form DoEvents Next End Sub Private Sub lvButtons_H1_Click() frmMain525.Show 1 End Sub Private Sub lvButtons_H2_Click() frmCustMaint.Show 1 End Sub Private Sub lvButtons_H3_Click() frmBackupDba.Show 1 End Sub Private Sub InitSearchListVw(LV As ListView) On Error GoTo InitErr Dim lItem As Long Dim lSubitem As Long For lItem = 1 To LV.ListItems.Count For lSubitem = 0 To LV.ColumnHeaders.Count - 1 If lSubitem = 0 Then LV.ListItems(lItem).Tag = LV.ListItems(lItem).Text Else LV.ListItems(lItem).Tag = LV.ListItems(lItem).Tag & ";" & _ LV.ListItems(lItem).SubItems(lSubitem) End If
K SK L ~ J L ~J ~J J J S PM LRP

Next lSubitem Next lItem LV.Tag = "Loaded " & lItem Debug.Print LV.Tag & " Items" InitErr: Select Case Err.Number Case 0: Case 91: Case Else: Debug.Print Err.Number; Err.Description End Select End Sub Private Sub lvButtons_H4_Click() Dim response As Integer response = MsgBox("?", vbYesNo + vbInformation, "") If response = vbYes Then End End If End Sub Private Sub lvButtons_H5_Click() frmMain.Show 1 End Sub Private Sub lvButtons_H6_Click() Text1.Text = "" End Sub Private Sub lvButtons_H7_Click() frmMain4.Show 1 End Sub Private Sub Text1_Change() ListView.ListItems.Clear Call dbConnect sql = "SELECT * FROM tbl_info WHERE info_name LIKE '" & Trim(Text1.Text) & "%'" Set rs = New ADODB.Recordset rs.Open sql, conn, adOpenDynamic, adLockOptimistic If Not rs.EOF Then Do Until rs.EOF

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Set Item = Me.ListView.ListItems.Add(, , rs!id_info, , "Custs") With ListView Item.SubItems(1) = rs!info_name Item.SubItems(2) = rs!info_address Item.SubItems(3) = rs!phone Item.SubItems(4) = rs!mobile Item.SubItems(5) = rs!mdate Item.SubItems(6) = rs!mone Item.SubItems(7) = rs!tech Item.SubItems(8) = rs!modle Item.SubItems(9) = rs!os Item.SubItems(10) = rs!ok End With rs.MoveNext cmdDelete.Enabled = True cmdEdit.Enabled = True cmdAdd.Enabled = True lvButtons_H4.Enabled = True lvButtons_H3.Enabled = True abc.Enabled = True lvButtons_H2.Enabled = True lvButtons_H5.Enabled = True cmdRefresh.Enabled = True Loop End If rs.Close: Set rs = Nothing End Sub Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer) Dim reply As Integer reply = MsgBox("?", vbInformation + vbYesNo, "") If reply = vbNo Then cancel = 1 End If End Sub Private Sub Timer3_Timer() Label2.Caption = Me.ListView.ListItems.Count End Sub Private Sub Timer4_Timer() Form11.Caption = " " End Sub Private Sub listview_Mouseup(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = 2 Then ' Me.PopupMenu mnuRightClick 'Show the popup menu
K SK L ~ J L ~J ~J J J S PO LRP

End If End Sub Private Sub mnuDelete_Click() End Sub Private Sub lvwPeople_KeyUp(KeyCode As Integer, Shift As Integer) End Sub Private Sub refresh_click() Call loadRecords End Sub Private Sub excel_click() Form125.Show 1 End Sub Private Sub info_Click() Form4414.Show 1 End Sub Private Sub details_Click() If Me.ListView.ListItems.Count = 0 Then MsgBox "", vbInformation, "" Exit Sub End If Form3.Show 1 End Sub Private Sub exit_Click() Unload Me End Sub. ------------------------------this form is named form 11 so far so good. now i made another form that contains 3 text boxes and i added a combobox by the way the name of the database in form 11 that holds the list is called "database" how do i connect to form 11 and displaying the user name in the combobox in the new form that i just created? like i said im new in vb 6 and i need a slow explanation . thanks for the help reply

help plsss..

Mon, 12/12/2011 - 03:33 Anonymous (not verified)

i had a problem using list view control... i made a program using the said control.... but when i load the program the column headers didn't appear on the screen... what should i do???... reply

Combobox

Wed, 03/02/2011 - 06:09 Arik

can i have your email if i have any questions to ask you about vb 6? reply

E-mail

Wed, 03/02/2011 - 12:59 C hrisGT7

Yes of course. Here it is: chrzgt7@hotmail.com reply

change text
3, 4, 5 and6 ? reply

Wed, 03/02/2011 - 15:26 Arik

what did you meen by Change the Index property of each text box to: 2,

combobox
the code worked perfect but i have en error

Wed, 03/02/2011 - 15:01 Arik

wrong number of arguments some thing like that reply

this error means, the object


you use the statement set Obj = listView.Addtime (...)

Mon, 02/07/2011 - 02:49 Muzammil (not verified)

this error means, the object which you are trying to use hasnt been set .. like

if this Obj hasnt been set and you try to use it you will get this "Object not set" error. The objects which are not set are actually nothing, and when you try to use them, you are trying to use nothing. reply

i have a question if you can help me

Thu, 02/10/2011 - 10:40 David27 (not verified)

i added to this database people that have to give me money and didnt pay yet..how do i caulculate the amount of the total money that the people needs to give me according to the database.. for example: joey needs to give me 500 dollars and didnt pay and greg didnt pay 300 . how can i show in a label the amount total of money that they didnt pay yet. please help me im kind of new in here thank you reply

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Sum the money


You have to use the SUM() in a SQL statement.

Sat, 02/19/2011 - 07:23 C hrisGT7

Let's say that the money you enter every time is stored in the table field named MoneyOwned. As you can understand, the label should display the sum of the MoneyOwned field. Here is what you have to do: mobjCmd.CommandText = "SELECT SUM(MoneyOwned) as PayMe FROM table_name" SET mobjRst = mobjCmd.Execute And finally: Label1.Caption = Format(mobjRst!PayMe, "$ #,##0.00") I believe this should work! Looking forward the results... reply

vb 6
ChrisGT7 u are a pro thanks for the help!!!!!!!!!!! reply

Fri, 03/25/2011 - 16:22 Arik

Arik
thank you worked :) reply

Mon, 02/28/2011 - 15:26 Arik

im using listview by the way


im using listview by the way reply

Thu, 02/10/2011 - 10:42 David27 (not verified)

error
soy what do i need to do to bot get this error? reply

Wed, 02/09/2011 - 16:23 Arik (not verified)

Please Help
the balance of tbStok can't update, please fix my code.....
K SK L ~ J L ~J ~J J J S

Wed, 01/05/2011 - 23:41 jasvorvan (not verified)

PRLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Private Sub cmdDel_Click() Dim a, kb, sat As String Dim qty, Balance As Double a = txtNo_Inv.Text Set rsA = New ADODB.Recordset rsA.Open "SELECT * From tbSalesDetail WHERE No_Inv ='" & a & "'", cn, adOpenDynamic, adLockOptimistic If rsA.RecordCount > 0 Then If MsgBox("Delete?", vbQuestion + vbYesNo, "Confirmation") = vbNo Then Exit Sub Else ''''''''''''''''''''XXXXXXXXXXXX"""""""" Set rsB = New ADODB.Recordset rsB.Open "SELECT * From tbSalesDetail WHERE No_Inv = '" & a & "'", cn, adOpenDynamic, adLockOptimistic If Not rsB.EOF Then rsB.MoveFirst Do While Not rsB.EOF kb = rsB.Fields(1).Value qty = rsB.Fields(2).Value sat = rsB.Fields(3).Value Set rsC = New ADODB.Recordset rsC.Open "SELECT * from tbStock WHERE Item_Code = '" & kb & "'", cn, adOpenDynamic, adLockOptimistic If rsC.EOF Then Set rsD = New ADODB.Recordset rsD.Open "SELECT * From tbStock", cn, adOpenDynamic, adLockOptimistic rsD.AddNew rsD.Fields(0).Value = kb rsD.Fields(1).Value = qty rsD.Fields(2).Value = sat rsD.Update rsD.Requery Else Set rsE = New ADODB.Recordset rsE.Open "SELECT * from tbStock WHERE Item_Code = '" & kb & "'", cn, adOpenDynamic, adLockOptimistic rsE.Clone Balance = rsE.Fields(1).Value Balance = Val(Format(Balance + qty)) End If If Not rsB.EOF Then rsB.MoveNext End If Loop End If '''''''''ZZZZZZZZZZ''''''''''' Set rsG = New ADODB.Recordset rsG.Open "SELECT * From tbSales WHERE No_Inv = '" & a & "'", cn, adOpenDynamic, adLockOptimistic If Not rsG.EOF Then Set rsF = New ADODB.Recordset
K SK L ~ J L ~J ~J J J S PSLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

rsF.Open "SELECT tbSalesDetail.*, tbSalesDetail.No_Inv FROM tbSalesDetail WHERE (tbSalesDetail.No_Inv = '" & a & "')", cn, adOpenDynamic, adLockOptimistic If Not rsF.EOF Then Do Until rsF.EOF rsF.Delete rsF.MoveNext Loop End If rsG.Delete End If End If End If ListView1.ListItems.Clear Form_Load txtNo_Inv.Enabled = True txtNo_Inv.SetFocus End Sub reply

visual basic (listview)

Tue, 11/23/2010 - 06:29 MUTHINI

please please i need your help! am a student in college and am doing a project on HRM system. Now i want to produce a system which will allow users to select/choose specific records from access database and then displayed on listview. reply

list view

Mon, 10/11/2010 - 22:17 codecs-VBpro (not verified)

..i want help.. I had used a list view control in the enrollment system we were asked to do as a completion for modeling and simulation subject. but i have no idea on how could i move the records shown in the list view to my data report....i have not yet tried that but i doubt i can't do this on my own...so thanks i found this site..maybe you can help me...I expect an answer to my problem...please help me...our defense is set on Oct. 29,'10....please... i really need your help.....anyway...the examples above is a big help....it's too long....but i can use it...thank you.... reply

VB6 inventory
Could anyone help me for my inventory system ?

Tue, 10/05/2010 - 09:59 Anonymous (not verified)

I'm trying to subtract some value in my table using data environment with a particular ID number . it only works in the first record . could anyone help me for my case study project ?

K SK L ~ J L ~J ~J J J S

PTLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

thanks in advance reply

auto select using mouse scroll with 3 listview control


Please urgent I have 3 listview control LV a = table customer LV b = table work order confirmation (woc) LV c = table product

Fri, 09/10/2010 - 12:51 indr4w (not verified)

How to selected row When LV a i am move scroll up or down using mouse then LV b automatic view work order by id customer and LV c automatic show product by no woc...? Thanks reply

Please help me

Sat, 09/04/2010 - 06:59 Ritche Lim (not verified)

please help me for a simple code to connect a database to a listview.. im only a begginer, please give me a simple code. using module... bec im making a project about inventory system.. please please help me.. just e mail me at motonoaji69@gmail.com. tnx a LOT! hope u will help me.. reply

Hard

Fri, 08/13/2010 - 18:39 Gaurab Parajuli ( A vb Programmer ) (not verified)

this is a mess for begineers programmer who want to start with using ADODB in vb6. reply

db list control
cfdfsir, i want the coding of databound list control 6.0. plz help me reply

Mon, 06/28/2010 - 03:42 vishi (not verified)

ListView

Thu, 05/06/2010 - 01:01 maghsoud (not verified)

I have a problem in ListView and also in ListBox control, "I couldn't add more than 100 items" so what shoud i do?
K SK L ~ J L ~J ~J J J S PULRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

reply

Please Help me!!!! What


Please Help me!!!!

Thu, 04/08/2010 - 21:01 Roland Boyles (not verified)

What control in visualbasic6 should i use when i want to capture a picture?? and How?? reply

Find no part in the program

Thu, 02/25/2010 - 17:26 Albert Enilone (not verified)

Sper bir uygulama jack sana katlyorum Birde arama ksm olsayd programda ok daha gzel olabilirdi. Jack sana yardm etmek isterdim ama listview de basit bir arama kodu bende mevcut istersen yazabilirim reply

So... Command Find Button?


those here who will write code to friends, thank you ...

Thu, 02/25/2010 - 17:22 Jack Human (not verified)

Very nice application, but only one found, the search button is missing if someone can help me if I remain grateful to In the meantime get from the database search code or search code, or get in listview I need urgent matter reply

About Coding
Sir We need the following buttons coding with handler of debug.

Tue, 03/23/2010 - 04:19 sher shah (not verified)

New, Next, Privious, Last, First, Delete, Search, Find, Combo box with reports, List box with combo, Calander Date with form, Calender Date with reports etc Thanks. Sher_bci@yahoo.com reply

Listview
Hi how to listview search / find ??? Please help me reply

Thu, 02/25/2010 - 17:14 Anonymous (not verified)

K SK L ~ J L ~J ~J J J S

PVLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

List View
Hi,

Tue, 02/23/2010 - 02:12 RassKass (not verified)

is it possible to type directly into the list view and save? i have a listview that i have customezed with column headers and codes to include grid lines now i just wanna be able to type text and save to an access data base, the followin is my code for grid lines Private Sub chkGridLines_Click() Dim rStyle As Long Dim r As Long 'get the current ListView style rStyle = SendMessageLong(txtSiteHist.hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0&, 0&) If chkSelectMode.Value = 0 Then 'remove the extended bit rStyle = rStyle Xor LVS_EX_GRIDLINES ElseIf chkSelectMode.Value = 1 Then 'set the extended bit rStyle = rStyle Or LVS_EX_GRIDLINES End If 'set the new ListView style r = SendMessageLong(txtSiteHist.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0&, rStyle) End Sub i would have loved to post a screen shot of the list view with grid lines, anyways please assist me with this problem or if there is another alternative control that can help me achieve the same results, Thanks, Regards reply

Listview
Where can I find that listviewcontrol? I can't find it...pls suggest me.. thanks... reply

Thu, 01/21/2010 - 20:28 Anonymous (not verified)

Add "Microsoft Windows

Tue, 03/23/2010 - 05:17 Anonymous (not verified)

Add "Microsoft Windows Common Control 6.0" from componnents in VB 6.0 reply

K SK L ~ J L ~J ~J J J S

Q LRP M

Great Help
me how in a couple of hours.

Sun, 01/17/2010 - 00:09 alvinccruz

I'm studying vb6 for a while and I find it difficult to understand how to use the ListView control. This Tutorial thought

To further my study, I created my own program using ListView. It was a success... but... with one funny difference. The selected record loses its highlight when I press any action buttons. I scanned my codes for possible errors, even compared it line by line with the tutorial... Until, I check each object properties. Fortunately, the first object I checked is the ListView control itself, its my newest control anyway. The problem lies in the ListView Property: HideSelection (default is True) with the following description: Determines whether the selected item will display as selected "when the ListView loses focus". Which is exactly was what happening as I navigate my training project. I'm actually happy to see this property, now my training project is almost as good as the tutorial. I hope, when I create a real application, I can surpass the tutorial though. Thanks, its a great help and exercise. reply

Good coding
Good coding reply

Sun, 02/21/2010 - 23:55 Anonymous (not verified)

Thank you very much.


Thank you very much. reply

Sat, 12/26/2009 - 13:20 Anonymous (not verified)

Thank you
Thank you very much that was very helpfully best regards Walid reply

Thu, 12/10/2009 - 12:08 Walid (not verified)

want to write query of mssql from vb6 by using ado connection

Thu, 12/03/2009 - 02:28 shivesh pandey (not verified)

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

hello, please help me in writing query from visual basic 6 in mssql2000 in ado connection reply

Really great sample. Simple


Really great sample. Simple and to the pont. thanks. reply

Thu, 11/05/2009 - 16:24 Anonymous (not verified)

listview
components thanks! reply

Mon, 10/26/2009 - 23:51 Anonymous (not verified)

Where can you find that listviewcontrol? I can't find it. What is the name of the dll, ocx so I can add it to my

Wanna ask...
Nice code..it really did help me a lot.. thanks by the way what does this code mean "If Not ValidateFormFields Then Exit Sub"??? i was just curious... can anyone explain it to me??? reply

Thu, 10/01/2009 - 05:11 PrincTM (not verified)

Hi, I think the line "If Not


Hi,

Thu, 10/29/2009 - 18:00 Anonymous (not verified)

I think the line "If Not ValidateFormFields Then Exit Sub" means if the validation of the data is not successful program will not proceed with the Save operation. The function should contain whatever the validation is necessary for each inputted data. To the author of the program, Thanks a lot, this has helped me so much.... reply

cool
K SK L ~ J L ~J ~J J J S

Sat, 09/19/2009 - 01:17 Tejashree (not verified)

Q LRP O

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

thanks i was searching for the same thing....got it reply

thanks
i had know about listview control but you told me how to implement it... the information provided by you is fantastic and very useful i m show much thankful to u reply

Sat, 08/08/2009 - 12:03 kedar (not verified)

Too long!
Too long! reply

Fri, 08/07/2009 - 00:31 Anonymous (not verified)

IWHNE I RUN THE PROJECT . IT


Can't find the project or lib. """ reply

Sun, 06/28/2009 - 19:18 Anonymous (not verified)

IWHNE I RUN THE PROJECT . IT SHOW THE ERROR MESSAGE "Private Sub PopulateListItem(pobjListItem As ListItem)"

mblnUpdateInProgress
what is the function of mblnUpdateInProgress in this code? reply

Mon, 05/18/2009 - 17:20 grace (not verified)

The purpose of

Wed, 06/24/2009 - 09:23 Anonymous (not verified)

The purpose of mblnUpdateInProgress, to me, is so that if the user attempts to close the application while UpdateInProgress is flagged TRUE, the msgbox will fire telling the user to finish their current action before closing the window. reply

Using with VBA


K SK L ~ J L ~J ~J J J S

Tue, 05/12/2009 - 00:37 Phoenix (not verified) Q PLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Hi. Ive a question about this great VB example. Is there a possibility to use in VBA? I tried to customize but I wasn't succesful. Could anybody help me please? Greets Phoenix reply

No it cannot.
No it cannot. reply

Sun, 07/26/2009 - 23:16 DaveC S (not verified)

lvw with vba cannot ? Yes it can


Hello, I'm currently using it in a MsAccess vba project To use it :

Thu, 07/01/2010 - 04:03 daniel C lerbois (not verified)

in your MsAccess project, call the vba dev interface (ALT + F11 key) Tools > References > search for: c:\windows\system32\mscomct2.ocx it will add Microsoft Common Controls-2 6.0 (SP4) to your project and then you will be able to drag/drop the Listview control into your form give it a name (lvwMain for instance) And then in your project you simply declare and set the listview object; note : in fact in MsAccess you don't have to declare the object if you code into your form, it is recognized by its name already ( me.LvwMain....) Dim Lvw1 as MSComctlLib.ListView set Lvw1 = me.lvwMain.Object Dim lvWidth As Integer lvWidth = Me.lvwMain.Width 'Set listview object presentation With lvw1 .View = lvwReport .GridLines = True .FullRowSelect = True .LabelEdit = lvwManual .ListItems.Clear End With 'add column headers With lvw1 .ColumnHeaders.Clear .ColumnHeaders.Add , , "{@COID}", lvWidth * 0.10, lvwColumnLeft
K SK L ~ J L ~J ~J J J S Q LRP Q

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

.ColumnHeaders.Add , , "{@COL1}", lvWidth * 0.15, lvwColumnCenter .ColumnHeaders.Add , , "{@COL2}", lvWidth * 0.12, lvwColumnCenter End With ..etc.... and there you go; hope this will help; and anyway, the sample is useful, quite complete and clear, thanks again Dan. reply

cmdSave
what is mstrMaintMode? reply

Wed, 05/06/2009 - 18:27 grace (not verified)

wow

Tue, 05/05/2009 - 08:56 jeraldo (not verified)

thanks for this! this can help me complete my project at school. its been 2 years and i havent done it yet. its keeping me from graduating! anyways, thanks a lot. i love vb6 and i hope i learn vb.net soon. thanks really! cheers here from the Philippines. reply

goog yar thanks very much


hey good job yar great thnx ..ossam keep it up thnks a lot reply

Fri, 05/01/2009 - 02:22 jayesh (not verified)

nice.....
simple codes ... easy to understand.. thanks.. this would help a LOT. reply

Sat, 04/04/2009 - 00:33 Anonymous (not verified)

K SK L ~ J L ~J ~J J J S

Q RLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Excellent work, Yet very simple and nice coding...


Hi, Dude

Thu, 03/26/2009 - 08:39 ATQ.BLR.IND (not verified)

Being an expert in VB for a decade i use controls when i really need it. for a quick search and easy to understand code, i recomend all new to vb and experts like me to check the code above. for RAD development. Thanks again, God Bless. reply

vb application

Wed, 03/25/2009 - 02:08 otema george (not verified)

i wonder why the site has provided all the codes for vb applicattion but with the exception of "search command" cant u put the search command just as uve put the other commands? reply

Datagrid Control
Hello VBProgrammer,

Tue, 03/24/2009 - 19:35 mindbugs (not verified)

Your program is very WOW! for me as a beginner programmer in VB. Can you help me do the same program but using the Datagrid Control instead of the listview? please email me :( Your help is very much appreciated..Thank you very much..More Power!! :)) reply

Pl.help me for master/detail form using adodc and data grid


In a master detail form, adodc and datagrid control is required .

Mon, 07/20/2009 - 05:09 Anonymous (not verified)

I am just beginer in vb6. I want to design a form for Invoicing/Billing. If anyone send me source code of the program. I really will be grateful. Thanks Balaram Dey reply

Simple and Very Useful product


Dear Guruji, excellent work. Congatulattions!

Tue, 03/10/2009 - 07:42 Udaya K (not verified)

K SK L ~ J L ~J ~J J J S

Q SLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Regards, udaya K. reply

Best Sample for me


Best regards reply

Wed, 03/04/2009 - 06:48 Amir bahmanian (not verified)

Thank you
thank you for providing such a perfect help.. thanx a lot :) reply

Sat, 02/28/2009 - 06:34 Abhirup (not verified)

listview icons
thank you nice and simple code pls send me simple code to add an icon to list view regards reply

Tue, 02/24/2009 - 02:25 wakhuta (not verified)

how about...
email the revise/addtional code email:molfato@yahoo.com reply

Fri, 01/16/2009 - 22:08 mike_olfato (not verified)

this useful for a beginner like me. how about you add an option for a "SEARCH". the rest is perfect. hope you could

its really good but beginars


its really good but beginars using access database cannot use this reply

Sat, 12/20/2008 - 02:01 Anonymous (not verified)

Listview display problem


K SK L ~ J L ~J ~J J J S

Thu, 12/04/2008 - 15:26 Anonymous (not verified)

Q TLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Just what i was looking for. 1 small problem i got, is that listview displays rubbish characters (greek language is used on the table of the mdb), probably problem with utf-8. Any solution suggested? reply

IS THIS CODE APPLICABLE IN MSSQL SERVER 2005?

Sun, 11/30/2008 - 02:59 Anonymous (not verified)

is there anyone has a code sample shown above using MSSQL SERVER 2005? email me pls.... i nid help.... wendeered@gmail.com.... tnx 2 som1 hu wil help me.... i wil wait 4 ur help.... reply

I'm trying to add 3 more


they dont exist.

Mon, 10/20/2008 - 00:42 Jonathan (not verified)

I'm trying to add 3 more fields to be updated into the database but when i add the code for the fields its almost like

keeps telling me either my update SQL statement is wrong or my insert into is wrong depending if i choose add or update the 3 fields im trying to add are year make and model please email if you can help jcobb5728@charter.net reply

HELLO FOR THE FIRST TIME


PLEASE I NEED TO UNDERSTAND SOMETHING..

Sat, 10/04/2008 - 16:21 jtoutou

if you are using sql server and you make a connection with a server using a connections tring,you must also use the microsoft jet 4 oledb connection for handling the records???? reply

very good
very good reply

Wed, 09/24/2008 - 19:12 Anonymous (not verified)

using ADO
TNX it really helps me reply
K SK L ~ J L ~J ~J J J S

Tue, 08/12/2008 - 02:38 che (not verified)

Q ULRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

how to add a find button???


very informative. i just want to ask on how to add a find button? reply

Sun, 08/10/2008 - 20:49 SamRas (not verified)

TreeView and Show data to Text box/ Grid.

Wed, 08/06/2008 - 22:14 C .J.Raghu (not verified)

Please help me. How to using Ado connection TreeView and Show data to Text box/ Grid. reply

how to edit ado in vb6 runtime


the code. i was so thankful if you have those simplest code reply

Fri, 07/25/2008 - 05:35 Anonymous (not verified)

can you have a simple code not in the list below because its to hard to understand. my approach in vb6 is different in

Can i have a complete code of Customer Table Maintenance


Hi, can u give a complete code of this example.. please send it thru my emai address.. Your favor is very much appreciated reply

Thu, 07/17/2008 - 23:44 Anonymous (not verified)

Thank you...

Fri, 07/11/2008 - 00:30 tahder (not verified)

Very informative site.... especially learning the ADO but it is very well explained that a reader will surely understand the basic of it... Through it i able to expand my confusions on connecting a database... This make a foundations for every programmer to be... and a reference for those intermediate and even expert... I salute you TheVBProgrammer for doing a great jobs... making a complicated things easier... Keep up the good works... reply

where can i download this


where can i download this program

Mon, 07/07/2008 - 06:39 Anonymous (not verified)

K SK L ~ J L ~J ~J J J S

Q VLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

reply

vb6
I HAVE SEEN BUTTONS WITH ICON, HOW DO I DO THAT reply

Sun, 08/01/2010 - 16:06 mikethehorse (not verified)

see above the line where it


see above the line where it is written "Hw did u like this article" there you will find a link download the application here... click on link reply

Mon, 07/07/2008 - 23:12 jassi (not verified)

Well Done...Yipeeeeeeee...!!!!
Thanx a lot Dear A nice coding Thankyou so much reply

Tue, 07/01/2008 - 13:29 Jassi (not verified)

Thanks very much! It's


Thanks very much! It's interesting! reply

Mon, 06/30/2008 - 01:21 Anonymous (not verified)

Visual Basic 6.0 Tutorials

Thu, 06/26/2008 - 05:53 Lewis Faith (not verified)

I enjoyed your tutorial on using ADO and the listing control but since i am still a beginner i would like you to send me the breakdown of vb6.0 tutorial so that i could learn, grow and become a great programmer like you. I would be gratefull if my request is granted. Just keep up with the good work and God Bless Thanks reply

Great!!!
K SK L ~ J L ~J ~J J J S

Thu, 02/28/2008 - 14:00 Anonymous RM LRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

This is good stuff, learned a lot just browsing the code! reply

more

Thu, 02/14/2008 - 02:09 Anonymous

how about the checkbox option? a minimal lecture will be greatly appriciated. thanx selecting the listview and getting its value on the second 3rd or forth row, will be good to those who want to enhance their skills. reply

excellent
thanks for the help reply

Tue, 12/11/2007 - 13:02 Anonymous

Using ADO and the ListView control


thank you very much...the information presented here helped me a lot. thank you reply

Mon, 09/03/2007 - 20:59 Anonymous

Ado sample
Thank's A lot. reply

Fri, 06/01/2007 - 13:32 Anonymous

Good
Malo aupito. Oku faka'ofo'ofa Thank you very much reply

Thu, 08/30/2007 - 18:38 Anonymous

Using Ado connection TreeView and Show data


Dear Vb Coder, Congratulation.

Sat, 05/05/2007 - 22:30 Anonymous

Using Ado and ListView Control code is fine. Please help me. How to using Ado connection TreeView and Show data to
K SK L ~ J L ~J ~J J J S RNLRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

Text box/ Grid. reply

Post new comment


Your name: Anonymous E-mail:
The conte nt of this fie ld is k e pt private and will not be shown publicly.

Homepage:

Subject:

Comment: *

Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> Lines and paragraphs break automatically.

More information about formatting options

Preview

Unless otherwise noted, all content on this site and in the source samples is Copyrighted 2011 by the owner of vb6.us. All rights reserved - Contact Information
K SK L ~ J L ~J ~J J J S RO LRP

NO LNO LQ

r = a l = ^ ~= i = = s == ~_~ S=s _SF s = = E

K SK L ~ J L ~J ~J J J S

RPLRP

Вам также может понравиться