Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

for statement problems

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
stoliD
Asked:
stoliD
1 Solution
 
bobbit31Commented:
missing semi colon

String fname = Form1->ListBox1->Items->Strings[h];
0
 
jkrCommented:
>>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
 
stoliDAuthor Commented:
hmm still doesnt work, got the missing statement ; error only now :(
0
 
nagubalaCommented:
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
 
stoliDAuthor Commented:
thx got it to work now :D
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now