|
-
Nov 16th, 2003, 02:10 AM
#1
Thread Starter
New Member
listbox to use Product Name........
i'm filling a listbox to fill with *.exe files that are in a specified directory. these show up just fine. their Name is cr100.exe and cr200.exe. what i need help in figuring out is how to set the .Displaymember property to display the individual .exe files' Product Name.
i've created the .exe's they are reports. so i've given the attributes of the files Product name to have something in English. like Inventory Listing, and Balance Sheet. This is what i want to display in the listbox.
thanks, i'd appreciate some guidance here.
-
Nov 16th, 2003, 02:56 AM
#2
New Member
How about something like this
Code:
Dim x as int16
dim ShortFilename as string
'exefilename = the full name of the file
ShortFilename = exefilename.substring(0,len(exefilename)-5) 'length - .exe(4 characters)-1
You can also use the len or filename.length
Hope this help
-
Nov 16th, 2003, 09:35 AM
#3
Thread Starter
New Member
not fullname, need Product Name
thanks for the reply, but i have no problem getting or displaying the Fullname of the EXE's in the listbox.
here is my code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
sReportPath = GetProgPath()
Dim di As New DirectoryInfo(sReportPath)
With lstAvailReports
.DataSource = di.GetFiles("*.exe")
.DisplayMember = FileVersionInfo.GetVersionInfo(.DataSource)
End With
my line with the .DisplayMember = is wrong, but it's what i'm trying to get at.
the fullname is loaded in the datasource, as c:\program files\dc shell\cr100.exe and is index 0, the next file is index 1, etc.
if you look at the properties of an EXE file, one of the attributes is the Product Name. which is what i want to display in the listbox. ie. cr100.exe = Inventory Listing, but it needs to set for each file in the array for .datasource.
-
Nov 16th, 2003, 09:56 AM
#4
New Member
Try doing a text search use substring and a for loop to run through the code
Code:
dim x as int16
dim filename as string
for x = len(exefilename) downto 0
if exefilename.substring(x,1) ="\" then
exit for
else
filename &=exefilename.substring(x,1)
endif
next
Ths way you search from the back of the string forward till you find the first "\" and then exits the loop
Hope this helps
-
Nov 16th, 2003, 10:19 AM
#5
Thread Starter
New Member
nope. but thanks
thanks for your prompt responses. but you are missing the entire concept. i'm not trying to parse out the name of the file. this is all being done in .net using some of the build in file and directory classes. i don't need to parse the file name. reread and understand my previous posts, regarding the subject.
thanks for trying.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|