?
Solved

for statement problems

Posted on 2003-02-20
5
Medium Priority
?
211 Views
Last Modified: 2010-04-01
void filenames()
{
for(int h=0; h<=Form1->ListBox1->Items->Count; h++){

        String fname = Form1->ListBox1->Items->Strings[h]

       *** for(int i = fname.Length(); i>=0; i--){
          if(fname.SubString(i, i-1)=="\\"){Form1->ListBox2->AddItem(fname);}
          break;}

          }
}

got this pile of code. get declaration syntax error, unknwon variable i and statement missing ; all in the marked line ***

no clue why, is there sth not correct? i just cant help myself what do i need to do to get this workin??? sorry im new so 35is all of my points :(
0
Comment
Question by:stoliD
[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
5 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 7987622
missing semi colon

String fname = Form1->ListBox1->Items->Strings[h];
0
 
LVL 86

Expert Comment

by:jkr
ID: 7987624
>>statement missing ;

Just add a ';' to the line above and it should work.

       String fname = Form1->ListBox1->Items->Strings[h]

should actually be

       String fname = Form1->ListBox1->Items->Strings[h];
0
 
LVL 1

Author Comment

by:stoliD
ID: 7987686
hmm still doesnt work, got the missing statement ; error only now :(
0
 

Accepted Solution

by:
nagubala earned 105 total points
ID: 7988603
If u r compiling in VC++, u have to do the following. See the first 3 lines below.

#include <string>
#include <iostream>
using namespace std ;

void filenames()
{
 for(int h=0; h<=Form1->ListBox1->Items->Count; h++)
 {
   string fname = Form1->ListBox1->Items->Strings[h];
   for(int i = fname.Length(); i>=0; i--)
   {
    if(fname.SubString(i, i-1)=="\\")
    {
     Form1->ListBox2->AddItem(fname);
    }
    break;
   }
 }
}

Note that the string class is declared as 'string' and not 'String'.

If this helps you I am happy.
0
 
LVL 1

Author Comment

by:stoliD
ID: 7989392
thx got it to work now :D
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

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