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

New to .net - Excel question

Kay
Hi All,

After I upgrade my vb6 app to dot net I got the following error:

=============
If .Cells._Default(iRow, 1) = "blar" Then
or
If .Cells(iRow, 1) = "blar" Then

An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll

Additional information: Operator is not valid for type 'Range' and string
"blar".
===============

Can someone show me how to read and write excel file using the excel object
instead of using ADO? Coz the app will manipulate the worksheet a lot and I
feel that using the excel object is a bit easier to access to a particular
cell (and save me some time to re-write the sub)...

Thanks in advance~

Kay


Nov 21 '05 #1
2 1112
Hi,

If .Cells(iRow, 1) .ToString= "blar" Then
Ken
---------------------
"Kay" <kk@micxsoft.com> wrote in message
news:eh**************@TK2MSFTNGP10.phx.gbl...
Hi All,

After I upgrade my vb6 app to dot net I got the following error:

=============
If .Cells._Default(iRow, 1) = "blar" Then
or
If .Cells(iRow, 1) = "blar" Then

An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll

Additional information: Operator is not valid for type 'Range' and string
"blar".
===============

Can someone show me how to read and write excel file using the excel object
instead of using ADO? Coz the app will manipulate the worksheet a lot and I
feel that using the excel object is a bit easier to access to a particular
cell (and save me some time to re-write the sub)...

Thanks in advance~

Kay



Nov 21 '05 #2
Kay
Thanks Ken~

Can someone also point me to a resource with the excel object example too?
Coz there are few more problmes and would like to learn more, thanks !!

Kay

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uk**************@TK2MSFTNGP09.phx.gbl...
Hi,

If .Cells(iRow, 1) .ToString= "blar" Then
Ken
---------------------
"Kay" <kk@micxsoft.com> wrote in message
news:eh**************@TK2MSFTNGP10.phx.gbl...
Hi All,

After I upgrade my vb6 app to dot net I got the following error:

=============
If .Cells._Default(iRow, 1) = "blar" Then
or
If .Cells(iRow, 1) = "blar" Then

An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll

Additional information: Operator is not valid for type 'Range' and string
"blar".
===============

Can someone show me how to read and write excel file using the excel
object
instead of using ADO? Coz the app will manipulate the worksheet a lot and
I
feel that using the excel object is a bit easier to access to a particular
cell (and save me some time to re-write the sub)...

Thanks in advance~

Kay


Nov 21 '05 #3

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

Similar topics

12
by: jimserac | last post by:
I had previously posted this in an Access forum with negative results so will try here. Although this question specifies an Access database, I also wish to accomplish this with a large MS SQL...
6
by: Sam Johnson | last post by:
HI I tried to send the following SQL string to an open databse, to export a table into excel format: g.Connection = conn 'valid OleDBConnection and Command objects g.CommandText = "SELECT *...
3
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
19
by: wreckingcru | last post by:
I'm trying to output a SQL query that is constructed thru my VB.net GUI into an excel file. Here is the code I'm using: 'Sqlstmt is the SQL query statement 'Conn is the SQL Connection object...
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
6
by: Gunawan | last post by:
Dear All, I have create an excel (COM Object) using this code Excel.Application xls = new Excel.Application(); but I can not remove it from memory although I have using close and quit ...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
7
by: ddecoste | last post by:
I have a need to add a visual representation to some data in Access. I need to draw a matix of squares inside another square. I have all the data that I need in a record in Access. The data...
3
by: pleaseexplaintome_2 | last post by:
using the code below (some parts not included), I create a new excel workbook with spreadheets. I then want to delete a spreadsheet, but a reference remains open and excel stays in task manager...
3
by: akristensen | last post by:
I am new to this site, so be patient if I do not ask the question correctly. Current Target Platform: Browser: MS IE, script language: Javascript (will use VBScript, but JS is preferred), External...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...

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.