Solved

conditional operator syntax

Posted on 2003-12-06
4
312 Views
Last Modified: 2010-05-01
I have string that contains information i want after the sixth comma, but the code i've written here won't return true for the if statement and goes into an infinite loop. Is the conditional operator syntax inaccurate?

intCommaCount = 0
x = 0
Do While intCommaCount < 6
        letter = Mid(stgFileToAppend, x, 0)
        If letter = "," Then
            intCommaCount = intCommaCount + 1
            x = x + 1
        Else
            x = x + 1
        End If
Loop
0
Comment
Question by:sirjulio
[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
4 Comments
 
LVL 24

Expert Comment

by:R_Rajesh
ID: 9888029
Hi sirjulio,

str1 = "hello, how, do, you, do, my, dear"
s = Split(str1, ",")
MsgBox s(6)

here s(6) gives you the string after the sixth comma


Cheers!

Rajesh
0
 
LVL 24

Accepted Solution

by:
R_Rajesh earned 100 total points
ID: 9888053
the code you wrote can be modified like this:

intCommaCount = 0
x = 1
Do While intCommaCount < 6
letter = Mid(stgFileToAppend, x, 1)
If letter = "," Then
intCommaCount = intCommaCount + 1
End If
x = x + 1
Loop
finalstr = Right(stgFileToAppend, Len(stgFileToAppend) - x)
MsgBox finalstr



Rajesh
0
 
LVL 1

Author Comment

by:sirjulio
ID: 9888242
thanx rajesh

i overlooked that if i wanted the character to enter the string variable that the mid method's third variable (string length) has to be 1

u rock
0
 
LVL 24

Expert Comment

by:R_Rajesh
ID: 9888270
thanks for the grade :)
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

690 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