Solved

newbie: invalid qualifier compile error on string manipulation

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

809 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