Solved

treeview control in vb6 - kep value error

Posted on 2004-03-29
4
314 Views
Last Modified: 2008-03-17
I am trying to use treeview control in vb6. Its giving error with the key parameter as invalid key value when I am trying to add nodes at run time.
what type of value does the key parameter takes (String / int) ?
please help
0
Comment
Question by:rk75
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 25 total points
Comment Utility
The key must be a string, that is it must at least start with an alpha.  Then it can be alpha or numeric.

Many people (include me) want to use the key to hold an ID to the database.  What I do is append the letter K in front of the actual ID

Dim strKey as String
strKey = "K" & rs.fields("ID")
0
 

Author Comment

by:rk75
Comment Utility
Thanks!!
I got the solution. I was trying to assign a number as a string as key of a node.
I tried the concatenated alphanumeric value starting with an alpha and it worked!!!

0
 
LVL 15

Expert Comment

by:SRigney
Comment Utility
don't forget to grade it so the question is closed and I get the points.

Glad I could help.
0
 

Expert Comment

by:tomerps1
Comment Utility
Dear Friend

it will take parameter of string type. u can c this small code. I hope it will help u.




Private Sub LoadTree()
    Dim intCounter As Integer

    On Error GoTo errHandler
    Call OpenConnection
   
    strQuery = "SELECT * FROM tblSupplierMaster ORDER BY Name"
    Set objRdo = objConn.Execute(strQuery)
   
    While Not objRdo.EOF
        Set XNode = treeviewSupplier.Nodes.Add(, , "Key " & objRdo("SupplierCode"), objRdo("Name"))
        objRdo.MoveNext
    Wend
   
    objRdo.Close
    Call CloseConnection
   
    Exit Sub
   
errHandler:
    MsgBox Err.Description, vbCritical, ERROR_CAPTION
End Sub


0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now