Solved

newbie: invalid qualifier compile error on string manipulation

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

Industry Leaders: 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

685 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