Click here to Skip to main content
15,921,990 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralVB.NET Datasets Pin
Mahesh167913-Feb-05 22:11
Mahesh167913-Feb-05 22:11 
GeneralRe: VB.NET Datasets Pin
Dave Kreskowiak14-Feb-05 1:26
mveDave Kreskowiak14-Feb-05 1:26 
GeneralRe: VB.NET Datasets Pin
Virus Detecter16-Feb-05 0:28
Virus Detecter16-Feb-05 0:28 
GeneralTriggering Event - Access Form Pin
FuzMic13-Feb-05 19:29
FuzMic13-Feb-05 19:29 
GeneralRe: Triggering Event - Access Form Pin
Dave Kreskowiak14-Feb-05 5:18
mveDave Kreskowiak14-Feb-05 5:18 
GeneralRe: Triggering Event - Access Form Pin
Mike the Red14-Feb-05 8:22
Mike the Red14-Feb-05 8:22 
GeneralHi Mike Red & Dave Pin
FuzMic14-Feb-05 19:30
FuzMic14-Feb-05 19:30 
GeneralVb Reading from Excel Pin
greg 77713-Feb-05 18:58
greg 77713-Feb-05 18:58 
I need to read values from an excel spreadsheet into a string array in VB.NET.

I can read the cells with no problems if I take the values into single dimensional variables, but I get an error when I try to read into an array.
The code fragment is:
Dim filename As String
filename = "c:\pass\userlist.csv"
Dim intRows As Integer
Dim fqn() as string
Dim r, i As Integer
' Open the Workbook in excel
Dim xlApp As Excel.Application
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlApp.Visible = False
Dim xlWB As Excel.Workbook
Dim xls As Excel.Worksheet
xlWB = CType(xlApp.Workbooks.Open(filename), Excel.Workbook)
xls = CType(xlWB.Worksheets(1), Excel.Worksheet)

intRows = xls.UsedRange.Rows.Count
num = intRows - 1
' Scroll through all the rows and columns retrieving values.
i = 1

For i = 0 To num
fqn(i) = CType(xls.Cells(r, 1), Excel.Range).Text
Next
xlWB.Close(False)
xlApp.Quit()
xls = Nothing
xlWB = Nothing
xlApp = Nothing


The error generated is:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Additional information: Exception from HRESULT: 0x800A03EC.

I have added the Excel library reference (11.0)
Any help would be appreciated

Greg S

GeneralRich Text Field - Background Pin
TomVerkaaik13-Feb-05 17:26
TomVerkaaik13-Feb-05 17:26 
GeneralConnecting scanner Pin
Avanti Dharkar13-Feb-05 0:52
Avanti Dharkar13-Feb-05 0:52 
GeneralRe: Connecting scanner Pin
H@is@here18-Feb-05 10:14
H@is@here18-Feb-05 10:14 
GeneralRe: Connecting scanner Pin
Avanti Dharkar19-Feb-05 3:52
Avanti Dharkar19-Feb-05 3:52 
QuestionCan some Help me with this over kill i know but ? Pin
Delo12-Feb-05 20:42
Delo12-Feb-05 20:42 
AnswerRe: Can some Help me with this over kill i know but ? Pin
Dave Kreskowiak13-Feb-05 17:27
mveDave Kreskowiak13-Feb-05 17:27 
QuestionHow to call a procedure Pin
Mekong River12-Feb-05 16:23
Mekong River12-Feb-05 16:23 
AnswerRe: How to call a procedure Pin
mm_chanakaya12-Feb-05 16:33
mm_chanakaya12-Feb-05 16:33 
GeneralRe: How to call a procedure Pin
Mekong River13-Feb-05 3:15
Mekong River13-Feb-05 3:15 
AnswerRe: How to call a procedure Pin
rwestgraham12-Feb-05 17:53
rwestgraham12-Feb-05 17:53 
GeneralRe: How to call a procedure Pin
Mekong River13-Feb-05 3:14
Mekong River13-Feb-05 3:14 
Generalcutting video file Pin
mm_chanakaya12-Feb-05 8:48
mm_chanakaya12-Feb-05 8:48 
GeneralRe: cutting video file Pin
Mike the Red13-Feb-05 16:16
Mike the Red13-Feb-05 16:16 
GeneralRe: cutting video file Pin
mm_chanakaya14-Feb-05 5:57
mm_chanakaya14-Feb-05 5:57 
GeneralHelp controlling columns in datagrid Pin
Gaz@UK12-Feb-05 8:20
Gaz@UK12-Feb-05 8:20 
GeneralRe: Help controlling columns in datagrid Pin
Dave Kreskowiak14-Feb-05 4:53
mveDave Kreskowiak14-Feb-05 4:53 
GeneralRe: Help controlling columns in datagrid Pin
Gaz@UK14-Feb-05 21:38
Gaz@UK14-Feb-05 21:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.