473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

dropdown list array problem

I have managed to populate a dropdown box with a list of all files in
the current folder and even filtered them by the extension so that it
only displays the .mdb files. However, the menu seems to be holding
all of the items in the folder and displaying only the .mdb. This
seems to be a problem with the way I am defining the size of the
array. If I add my .mdb filter to the array loop I get an 'out of
range' error for the n variable?? Can anyone suggest a solution??
'Find Number of Files
varFileCount = 0

For Each objFile in objFolder.Files
varFileName = objFSO.GetFileName(objFile.Name)
varFileType = objFSO.GetExtensionName(objFile.Name)
If (Left(varFileType, 3) = "mdb") Then
varFileCount = varFileCount + 1
End if
Next

' Put File Names into an Array
ReDim varFileNames(varFileCount)
n = 0

For Each objFile in objFolder.Files
n = n + 1

' varFileName = objFSO.GetFileName(objFile.Name)
' varFileType = objFSO.GetExtensionName(objFile.Name)
' If (Left(varFileType, 3) = "mdb") Then

varFileNames(n) = objFile.Name

' End If

Next
Jul 19 '05 #1
2 4088
You can chuck all your filenames in an array like so. Note the usage of the
dynamic array dimmed with () and then Redimmed through the loop.
<%
Dim aFiles()
varFileCount = 0

For Each objFile in objFolder.Files
varFileName = objFSO.GetFileName(objFile.Name)
varFileType = objFSO.GetExtensionName(objFile.Name)
If (Left(varFileType, 3) = "mdb") Then

Redim Preserve aFiles(varFileCount)
aFiles(varFileCount) = varFileName

varFileCount = varFileCount + 1
End if
Next

Set objFolder = Nothing
Set objFSO = Nothing
%>

<select>
<% For i = 0 To UBound(aFiles) %>
<option value="<%=aFiles(i)%>"><%=aFiles(i)%></option>
<% Next %>
Ray at work

"djharrison" <da************@netscape.net> wrote in message
news:75**************************@posting.google.c om...
I have managed to populate a dropdown box with a list of all files in
the current folder and even filtered them by the extension so that it
only displays the .mdb files. However, the menu seems to be holding
all of the items in the folder and displaying only the .mdb. This
seems to be a problem with the way I am defining the size of the
array. If I add my .mdb filter to the array loop I get an 'out of
range' error for the n variable?? Can anyone suggest a solution??
'Find Number of Files
varFileCount = 0

For Each objFile in objFolder.Files
varFileName = objFSO.GetFileName(objFile.Name)
varFileType = objFSO.GetExtensionName(objFile.Name)
If (Left(varFileType, 3) = "mdb") Then
varFileCount = varFileCount + 1
End if
Next

' Put File Names into an Array
ReDim varFileNames(varFileCount)
n = 0

For Each objFile in objFolder.Files
n = n + 1

' varFileName = objFSO.GetFileName(objFile.Name)
' varFileType = objFSO.GetExtensionName(objFile.Name)
' If (Left(varFileType, 3) = "mdb") Then

varFileNames(n) = objFile.Name

' End If

Next

Jul 19 '05 #2
Thanks for the help. Works great.
Jul 19 '05 #3

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

Similar topics

4
by: Marc | last post by:
I've gotten everything up and running except for this -- I'd like to be able to have people have a dropdown list of cities in the US to use (or wherever) and not have to input them manually into a...
2
by: Tapiwa JONGWE | last post by:
I would like to display 15 items (lines) in the dropdown list, but by default the list displays only 11 lines. How can I have all the 15 items displayed in my dropdown list ? Thanks for your...
1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
4
by: anonymous | last post by:
Hi Folks, I have a form with two Dropdown list boxes, which get loaded with data from Database. DropDownList1 gets data from Table1 and DropDownList2 gets data from Table2 Table1 has a...
6
by: San Smith | last post by:
I have a dropdown list box with list of item. When I read the data from database I want to display that value(one of the item in the drop down box) in the dropdown list box. How to do that in a...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
4
by: Greg Scharlemann | last post by:
I'm trying to setup a dyamic dropdown list that displays a number of text fields based on the selected number in the dropdown. The problem I am running into is capturing the data already entered...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.