[If xlSheet.Cells(count, 1) = "" Then] Won't Work
[If xlSheet.Cells(count, 1) = "" Then] Won't Work
[If xlSheet.Cells(count, 1) = "" Then] Won't Work
[If xlSheet.Cells(count, 1) = "" Then] Won't Work
[If xlSheet.Cells(count, 1) = "" Then] Won't Work
[If xlSheet.Cells(count, 1) = "" Then] Won't Work [If xlSheet.Cells(count, 1) = "" Then] Won't Work [If xlSheet.Cells(count, 1) = "" Then] Won't Work [If xlSheet.Cells(count, 1) = "" Then] Won't Work [If xlSheet.Cells(count, 1) = "" Then] Won't Work [If xlSheet.Cells(count, 1) = "" Then] Won't Work [If xlSheet.Cells(count, 1) = "" Then] Won't Work [If xlSheet.Cells(count, 1) = "" Then] Won't Work
[If xlSheet.Cells(count, 1) = "" Then] Won't Work [If xlSheet.Cells(count, 1) = "" Then] Won't Work
[If xlSheet.Cells(count, 1) = "" Then] Won't Work
Go Back  Xtreme Visual Basic Talk > > > [If xlSheet.Cells(count, 1) = "" Then] Won't Work


Reply
 
Thread Tools Display Modes
  #1  
Old 03-03-2005, 05:52 PM
TexasAggie TexasAggie is offline
Junior Contributor
 
Join Date: Feb 2004
Location: San Antonio, TX
Posts: 286
Default Can Write to but not Read From Excel


Why wouldn't
Code:
If xlSheet.Cells(count, 1) = "" Then
work? It worked in 6.0. I'm trying to find the first empty row in a column. I can write data to Excel but I can't read data from it. This should be easy enough...



Full code:
Code:
For count = 1 To 10 If xlSheet.Cells.Item(count, 1) = "" Then Exit For End If cboName.Items.Add(xlSheet.Cells(count, 1)) Operator(count - 1).Name = xlSheet.Cells(count, 1) Operator(count - 1).Password = xlSheet.Cells(count, 2) If xlSheet.Cells(count, 3) = "T" Then Operator(count - 1).LastOn = True cboName.Text = Operator(count - 1).Name End If If xlSheet.Cells(count, 4) = "T" Then chkHelp.Checked = True Operator(count - 1).HelpFlag = True Else chkHelp.Checked = False End If Next

Thanks,

Last edited by TexasAggie; 03-03-2005 at 06:52 PM.
Reply With Quote
  #2  
Old 03-04-2005, 05:10 AM
herilane's Avatar
herilane[If xlSheet.Cells(count, 1) = "" Then] Won't Work herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

You should specify which property you are interested in - in this case the .Value property.
Code:
If xlSheet.Cells.Item(count, 1).Value = ""
Reply With Quote
  #3  
Old 03-04-2005, 08:30 AM
TexasAggie TexasAggie is offline
Junior Contributor
 
Join Date: Feb 2004
Location: San Antonio, TX
Posts: 286
Default

That works, but why is it that the only function that pops up on the end of that statement is "getType?"

Quote:
Originally Posted by herilane
You should specify which property you are interested in - in this case the .Value property.
Code:
If xlSheet.Cells.Item(count, 1).Value = ""
Reply With Quote
  #4  
Old 03-04-2005, 09:25 AM
herilane's Avatar
herilane[If xlSheet.Cells(count, 1) = "" Then] Won't Work herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

Cells(r, c) is technically a polymorphic method, even though I have no idea what other types it could be in addition to Excel.Range. (Possibly just sloppy implementation by MS? Don't know.) Coerce it to Excel.Range using CType if you want proper intellisense.
Code:
Dim xlRange As Excel.Range xlRange = CType(xlSheet.Cells.Item(count, 1)) If xlRange.Value... '<---- you should get intellisense here!
Turning Option Strict On would help you catch these cases, where an object is being cast to a different type implicitly.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work [If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work [If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work [If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work [If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work [If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work [If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work [If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
 
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
[If xlSheet.Cells(count, 1) = &quot;&quot; Then] Won't Work
 
-->