?
Solved

conditional operator syntax

Posted on 2003-12-06
4
Medium Priority
?
313 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 400 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
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…
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…
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

762 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