473,804 Members | 4,288 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetFileN ame(objFile.Nam e)
varFileType = objFSO.GetExten sionName(objFil e.Name)
If (Left(varFileTy pe, 3) = "mdb") Then
varFileCount = varFileCount + 1
End if
Next

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

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

' varFileName = objFSO.GetFileN ame(objFile.Nam e)
' varFileType = objFSO.GetExten sionName(objFil e.Name)
' If (Left(varFileTy pe, 3) = "mdb") Then

varFileNames(n) = objFile.Name

' End If

Next
Jul 19 '05 #1
2 4114
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.GetFileN ame(objFile.Nam e)
varFileType = objFSO.GetExten sionName(objFil e.Name)
If (Left(varFileTy pe, 3) = "mdb") Then

Redim Preserve aFiles(varFileC ount)
aFiles(varFileC ount) = varFileName

varFileCount = varFileCount + 1
End if
Next

Set objFolder = Nothing
Set objFSO = Nothing
%>

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

"djharrison " <da************ @netscape.net> wrote in message
news:75******** *************** ***@posting.goo gle.com...
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.GetFileN ame(objFile.Nam e)
varFileType = objFSO.GetExten sionName(objFil e.Name)
If (Left(varFileTy pe, 3) = "mdb") Then
varFileCount = varFileCount + 1
End if
Next

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

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

' varFileName = objFSO.GetFileN ame(objFile.Nam e)
' varFileType = objFSO.GetExten sionName(objFil e.Name)
' If (Left(varFileTy pe, 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
2034
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 text field. When you do then there are issues of misspellings, etc. Now I have a list of cities from each state that is a sample that works in an html page. Problem is that it takes up 2 MB! Way too much to load on a single page and I was...
2
2166
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 help.
1
8295
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 dropdown lists. If you change the selection of the left one (e.g. choose parentoption2), it should open up page2.htm in a popup window.
4
1803
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 parent child relationship with Table2 ( has a foreign key to Table1)
6
1550
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 dropdown list box ? San
2
4559
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 set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
0
2918
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 strDataValueField; string strDataTextField; public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
4
2638
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 before the list is repopulated. For example, suppose the user selects 3 in the drop down list and 3 text fields are shown. If the user populates the 3 text fields with data and decides to change the drop down to a list of 4 or 5, how do I capture...
4
4593
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 reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The frontend that users will see however, still needs some work. I'm really close, but since I'm no...
0
9589
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
10593
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
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
9163
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7626
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
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3000
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.