CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    1

    Unhappy VB : evaluate string

    Hi,

    I construct a string in my application like mystring= "insert into DRTABLE(field1,field2) values (MSFLEXGRID1.textmatrix(i,1), MSFLEXGRID.TEXTMATRIX(i,2))"

    Now i want to use this string in a for-loop :

    For i = 0 To MSFlexGrid1.Rows - 1 Step 1
    'in this statement the i should be replaced by the value of
    'the loop counter i
    'the replace function does not help, because the string is still
    'not taken as a statement which can be executed
    execute(mystring)
    Next i

    Anyone knows how i can do that ?

  2. #2
    Join Date
    Apr 2004
    Location
    Austria
    Posts
    43
    You want to insert everything the user had written to a flexgrid into the datebase

    start the for loop

    For
    execute("INSERT INTO ...")
    Next

    or you could do that

    For
    strCommand = strCommand & vbcrlf & "INSERT INTO.... ;"
    Next
    Execute(strCommand)

    hope that helped.

    greetings UNI

  3. #3
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210

    Re: VB : evaluate string

    Originally posted by jieves
    I construct a string in my application like mystring= "insert into DRTABLE(field1,field2) values (MSFLEXGRID1.textmatrix(i,1), MSFLEXGRID.TEXTMATRIX(i,2))"
    you need string concatination :
    Code:
    mystring="insert into DRTABLE(field1,field2) values(" & MSFLEXGRID1.textmatrix(i,1) & "," & MSFLEXGRID.TEXTMATRIX(i,2) & ")"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured