Solved

newbie: invalid qualifier compile error on string manipulation

Posted on 2004-04-07
5
1,090 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
  • 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now