473,698 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to use items in a list as a hyperlink

sam
Hi all,

Kindly have a look to the code given below
*************** *************** *************** *************** *************** **
Public Function CountFiles(strD ir As String, Optional SubDir As
Boolean) As Long

With Application.Fil eSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolde rs = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.cou nt
End If

For i = 1 To .FoundFiles.cou nt
Me.list1.AddIte m (.FoundFiles(i) )
Next i

End With
End Function
*************** *************** *************** *************** ************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\sub folder1\file1.d oc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam

Dec 19 '06 #1
4 1784
On 19 Dec 2006 03:54:34 -0800, "sam" <sa************ ****@gmail.com>
wrote:

I think the FileSearch object is a bit limited. Here is similar code
using the more powerful FileSystemObjec t:

Private Function fsoCountFiles(B yVal strDir As String)
Dim fso As Scripting.FileS ystemObject
Dim folder As Scripting.folde r
Dim file As Scripting.file

Set fso = New Scripting.FileS ystemObject
Set folder = fso.GetFolder(s trDir)
For Each file In folder.Files
Me.List4.AddIte m (file.Name)
Next file
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
End Function

Then the double-click event:
Private Sub List4_DblClick( Cancel As Integer)
Dim strFullName As String
'Text0 has the root for the search.
strFullName = Me.Text0.Value & "\" &
List4.ItemData( List4.ListIndex )
Application.Fol lowHyperlink strFullName
End Sub

-Tom.
>Hi all,

Kindly have a look to the code given below
************** *************** *************** *************** *************** ***
Public Function CountFiles(strD ir As String, Optional SubDir As
Boolean) As Long

With Application.Fil eSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolde rs = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.cou nt
End If

For i = 1 To .FoundFiles.cou nt
Me.list1.AddIte m (.FoundFiles(i) )
Next i

End With
End Function
************** *************** *************** *************** *************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\su bfolder1\file1. doc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam
Dec 19 '06 #2
sam
Thanks tom

when i am running your code it is giving me compile error on this line

List4.ItemData( List4.ListIndex )

for ItemData it says "invalid use of property"

is it because my list box is unbound
the values that are in the list are not bound to any field in the table
these values are just the name of the files in a particular folder
i just want to open these files on double click

is there any solution to this problem

sam
Tom van Stiphout wrote:
On 19 Dec 2006 03:54:34 -0800, "sam" <sa************ ****@gmail.com>
wrote:

I think the FileSearch object is a bit limited. Here is similar code
using the more powerful FileSystemObjec t:

Private Function fsoCountFiles(B yVal strDir As String)
Dim fso As Scripting.FileS ystemObject
Dim folder As Scripting.folde r
Dim file As Scripting.file

Set fso = New Scripting.FileS ystemObject
Set folder = fso.GetFolder(s trDir)
For Each file In folder.Files
Me.List4.AddIte m (file.Name)
Next file
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
End Function

Then the double-click event:
Private Sub List4_DblClick( Cancel As Integer)
Dim strFullName As String
'Text0 has the root for the search.
strFullName = Me.Text0.Value & "\" &
List4.ItemData( List4.ListIndex )
Application.Fol lowHyperlink strFullName
End Sub

-Tom.
Hi all,

Kindly have a look to the code given below
*************** *************** *************** *************** *************** **
Public Function CountFiles(strD ir As String, Optional SubDir As
Boolean) As Long

With Application.Fil eSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolde rs = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.cou nt
End If

For i = 1 To .FoundFiles.cou nt
Me.list1.AddIte m (.FoundFiles(i) )
Next i

End With
End Function
*************** *************** *************** *************** ************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\sub folder1\file1.d oc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam
Dec 20 '06 #3
On 20 Dec 2006 04:23:36 -0800, "sam" <sa************ ****@gmail.com>
wrote:

Mine was unbound as well. I was using Access 2003. You?
-Tom.

>Thanks tom

when i am running your code it is giving me compile error on this line

List4.ItemData (List4.ListInde x)

for ItemData it says "invalid use of property"

is it because my list box is unbound
the values that are in the list are not bound to any field in the table
these values are just the name of the files in a particular folder
i just want to open these files on double click

is there any solution to this problem

sam
Tom van Stiphout wrote:
>On 19 Dec 2006 03:54:34 -0800, "sam" <sa************ ****@gmail.com>
wrote:

I think the FileSearch object is a bit limited. Here is similar code
using the more powerful FileSystemObjec t:

Private Function fsoCountFiles(B yVal strDir As String)
Dim fso As Scripting.FileS ystemObject
Dim folder As Scripting.folde r
Dim file As Scripting.file

Set fso = New Scripting.FileS ystemObject
Set folder = fso.GetFolder(s trDir)
For Each file In folder.Files
Me.List4.AddIte m (file.Name)
Next file
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
End Function

Then the double-click event:
Private Sub List4_DblClick( Cancel As Integer)
Dim strFullName As String
'Text0 has the root for the search.
strFullName = Me.Text0.Value & "\" &
List4.ItemData (List4.ListInde x)
Application.Fol lowHyperlink strFullName
End Sub

-Tom.
>Hi all,

Kindly have a look to the code given below
************** *************** *************** *************** *************** ***
Public Function CountFiles(strD ir As String, Optional SubDir As
Boolean) As Long

With Application.Fil eSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolde rs = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.cou nt
End If

For i = 1 To .FoundFiles.cou nt
Me.list1.AddIte m (.FoundFiles(i) )
Next i

End With
End Function
************** *************** *************** *************** *************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\su bfolder1\file1. doc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam
Dec 20 '06 #4
sam
i am also using access 2003
i will just check may be i am making another mistake
reply you tomorrow

Tom van Stiphout wrote:
On 20 Dec 2006 04:23:36 -0800, "sam" <sa************ ****@gmail.com>
wrote:

Mine was unbound as well. I was using Access 2003. You?
-Tom.

Thanks tom

when i am running your code it is giving me compile error on this line

List4.ItemData( List4.ListIndex )

for ItemData it says "invalid use of property"

is it because my list box is unbound
the values that are in the list are not bound to any field in the table
these values are just the name of the files in a particular folder
i just want to open these files on double click

is there any solution to this problem

sam
Tom van Stiphout wrote:
On 19 Dec 2006 03:54:34 -0800, "sam" <sa************ ****@gmail.com>
wrote:

I think the FileSearch object is a bit limited. Here is similar code
using the more powerful FileSystemObjec t:

Private Function fsoCountFiles(B yVal strDir As String)
Dim fso As Scripting.FileS ystemObject
Dim folder As Scripting.folde r
Dim file As Scripting.file

Set fso = New Scripting.FileS ystemObject
Set folder = fso.GetFolder(s trDir)
For Each file In folder.Files
Me.List4.AddIte m (file.Name)
Next file
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
End Function

Then the double-click event:
Private Sub List4_DblClick( Cancel As Integer)
Dim strFullName As String
'Text0 has the root for the search.
strFullName = Me.Text0.Value & "\" &
List4.ItemData( List4.ListIndex )
Application.Fol lowHyperlink strFullName
End Sub

-Tom.

Hi all,

Kindly have a look to the code given below
*************** *************** *************** *************** *************** **
Public Function CountFiles(strD ir As String, Optional SubDir As
Boolean) As Long

With Application.Fil eSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolde rs = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.cou nt
End If

For i = 1 To .FoundFiles.cou nt
Me.list1.AddIte m (.FoundFiles(i) )
Next i

End With
End Function
*************** *************** *************** *************** ************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\sub folder1\file1.d oc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam
Dec 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2035
by: tabonni | last post by:
My situation is: I got two ASP pages. One is ASP email form (I'm using Persist ASP Email component). Another one has all file links in it. For example, when user click Outlook course hyperlink. It will pop up another window with outlook course PDF file. (All PDF files are already in the server). What I am trying to do is: When user click the "Add Email" hyperlink, it will add that course name and filepath into ASP/VBScript Dictioanry
3
1996
by: tabonni | last post by:
My situation is: I got two ASP pages. One is ASP email form (I'm using Persist ASP Email component). Another one has all file links in it. For example, when user click Outlook course hyperlink. It will pop up another window with outlook course PDF file. (All PDF files are already in the server). What I am trying to do is: When user click the "Add Email" hyperlink, it will add that course name and filepath into ASP/VBScript Dictioanry
5
1094
by: Tom | last post by:
Hi, I created a table with a field to store the full path of the uploading images The table scheme is i path //path to the uploading imag userid //who upload i Now, I want to display the image path in url, it only shows the images belong to that user. User can see that image by clicking the hyperlink
0
1027
by: Nick | last post by:
Hi, I have a Repeater control and want to bind a hyperlink to each repeated row. For this I can use the following syntax (excuse any incorrect naming but I don't have any code to hand): <asp:Hyperlink id="x" NavigateToUrl='<%# Bind("id", "Page.aspc?id={0}") %> Text="Text"></asp:Hyperlink> This all works find but I'd like to be able to bind 2 data items such
1
1295
by: diatom | last post by:
Hello, I have the items of a table bound to a DataGrid control on my web form. How would I go about letting the user click on an item in the DataGrid control to download the content. For example, lets say the contents of my DataGrid control are a list of articles. I want the user to be able to right-click the name of the article and save the .pdf on their machine.
8
1482
by: fiefie.niles | last post by:
I am new to ASP.Net. I use VB.NET as the language and Visual Studio ..NET 2003. On my WebForm I have a label called "Categories". I would like to read all the categories from the database and placed them under the label "Categories". I also would like each category to be a hyperlink to go to another page. How can I do that ? Using the codes below the categories are not placed under the label "Categories", and there is no hyperlink for...
1
2389
by: sanju | last post by:
Hi , I am displaying 5 photos of a user(getting image path from database) and binding them to hyperlink control and adding that Hyperlink control to Datalist container in code behind file. Now I want to change last 2 photos of user with another image while loading the page. My situation is "I want to hide/mask photos of user depending on the
1
2813
by: obs | last post by:
Hi. I'm using the following code to change a hyperlink attributes of a hyperlink which is located in an itemtemplate of a datalist. When I debug it the attributes are changed and everything is fine, but the end result is that all of the datalist items have the same hyperlink attributes. Somehow it goes to the last iteration of the for loop, and uses the values that are generated there. What am I missing ? I've been working on it for two...
7
1710
by: Clamato | last post by:
Hello everyone, I've been working on this for a bit and wonder if anyone can shed some light on my situation. My ultimate goal is to have a user select an item in a list box, have one column in the list box display in either a text box or preferrably a button based on what is selected. The form is being used currently as a rudimentary document retrieval system. The document that is saved on a shared drive is linked in a table by a...
0
8671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4613
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.