Solved

conditional operator syntax

Posted on 2003-12-06
4
311 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

726 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