Solved

conditional operator syntax

Posted on 2003-12-06
4
307 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks for the grade :)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now