473,394 Members | 1,679 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,394 software developers and data experts.

Errors appear in vb file only

Below is a section from my aspx web page. If I create the same but place
the function GetPhotos() in a separate vb file I get the following errors
underlined in blue:

List(Of String) - Type 'List' is not defined
Directory - Name 'Directory' is not declared
Path - Name 'Path' is not declared

Does anyone know why this is? Have I missed something obvious?

<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">

Public Function GetPhotos() As List(Of String)
Dim photos As New List(Of String)()
Dim photoPath As String = MapPath("~/Photos")
Dim files As String() = Directory.GetFiles(photoPath)
For Each photo As String In files
photos.Add("~/Photos/" + Path.GetFileName(photo))
Next
Return photos
End Function

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #1
1 1121
Ok, I've sorted it out. I needed to put the following 2 lines at the top
of the vb file:

Imports System.IO
Imports System.Collections.Generic


On Sun, 17 Dec 2006 11:17:25 -0000, DesCF <de***@aol.comwrote:
Below is a section from my aspx web page. If I create the same but
place the function GetPhotos() in a separate vb file I get the following
errors underlined in blue:

List(Of String) - Type 'List' is not defined
Directory - Name 'Directory' is not declared
Path - Name 'Path' is not declared

Does anyone know why this is? Have I missed something obvious?

<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">

Public Function GetPhotos() As List(Of String)
Dim photos As New List(Of String)()
Dim photoPath As String = MapPath("~/Photos")
Dim files As String() = Directory.GetFiles(photoPath)
For Each photo As String In files
photos.Add("~/Photos/" + Path.GetFileName(photo))
Next
Return photos
End Function


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #2

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

Similar topics

5
by: Michelle Kinsey-Clinton | last post by:
Hello, I am writing an ASP app which is giving me some very frustrating errors. They appear intermittently, no real pattern to them, and often go away if you reload, or back up a few pages and...
4
by: Morgan Leppink | last post by:
Hey all - We are running SQL 2000 with ALL available service packs, etc. applied. We just built a brand new database server, which has dual 2Ghz XEONs, 2GB memory, and the following disk...
6
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start...
19
by: mailbox | last post by:
In trying to build the Perl Curses module (Curses-1.12) under Perl 5.8 on a new AIX box I came up against the limits of my C as well as my Unix knowledge. The thing had built okay under Perl 5.6...
24
by: Massimo Soricetti | last post by:
Hello, I'm not a C newbie, but I'm teaching C programming (well... FIRST programming and then C) to other guys these days and it's driving me to some reflexions on the language. It's not...
3
by: Simon | last post by:
This problem has been driving me mad for months.... Seen a few posts on forums about it but no answers... No mention on MSDN etc. XP Pro SP1, VS.NET (c#) .Net framework 1.1, IIS 5.1. In a...
11
by: Roger Vale | last post by:
Hi all Visual studio 2005 Visual Basic windows mobile application I am getting this from the imediate window A first chance exception of type 'System.InvalidCastException' occurred in...
0
by: Gregory Gadow | last post by:
We have a number of development machines in our IT department, all running the same version of VS 2005 sp 1. Our company website and several compiled components were all written in VB.Net 2.0 using...
1
by: =?Utf-8?B?Q3VzdG9t?= | last post by:
I tried to update Vista OS to Vista SP1, when system restarts during installation it checks disk volume for errors, in the process of scaning disk if finds some errors as follows: Checking file...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.