Solved

conditional operator syntax

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

831 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