Solved

newbie: invalid qualifier compile error on string manipulation

Posted on 2004-04-07
5
1,187 Views
Last Modified: 2008-01-09
Hello,

I am trying to do some relatively simple parsing of some text in an Excel file, and I'm using Excel 2002 macro language, Visual Basic 6.3. I haven't used VB much, but I've found lots of string manipulation examples. However I can't seem to use any String methods! This very simple example does not work:

Sub testparse()
    Range("A1").Select
    Dim sCurCell As String            
    Dim iCurCellLength As Integer    

    sCurCell = ActiveCell.Value
    iCurCellLength = sCurCell.Length
End Sub

When run, I get a "Compile error: Invalid qualifier" on the last row, and the 'sCurCell' part is highlighted.

Any clues? Thanks!

Leah
0
Comment
Question by:lzagreus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
BrianGEFF719 earned 125 total points
ID: 10779663
sCurCell is defined as a  string so you need to use the LEN() function.


Sub testparse()
    Range("A1").Select
    Dim sCurCell As String            
    Dim iCurCellLength As Integer    

    sCurCell = ActiveCell.Value
    iCurCellLength = len(sCurCell)
End Sub



-Brian
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10779670
Test it out like this:


Sub testparse()
    Range("A1").Select
    Dim sCurCell As String            
    Dim iCurCellLength As Integer    
    sCurCell = ActiveCell.Value
    iCurCellLength = len(sCurCell)
    msgbox "Cell A1 Contains: " & sCurCell & ", which has a length of " & iCurCellLength
End Sub



Good Luck
-Brian
0
 

Author Comment

by:lzagreus
ID: 10779726
Thank you! I see now that I need to use functions like InStr() rather than String.IndexOf() too. Why doesn't VB let me use String methods on things that I've declared as Strings? Bizarre. Anyway, thanks for the help.
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10779741
You are using VB 6 VBA, not .NET

Thats your problem, you are using code for .NET not vb6.

String.IndexOf() <---VB .NET
MID() <--- vb6



Good Luck
-Brian
0
 

Author Comment

by:lzagreus
ID: 10780216
Thanks for the info. You've been very concise and helpful.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month5 days, 18 hours left to enroll

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question