Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

newbie: invalid qualifier compile error on string manipulation

Posted on 2004-04-07
5
Medium Priority
?
1,273 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 500 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
Suggested Courses

927 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