Results 1 to 3 of 3

Thread: problem with compare the value of textbox with datatable rows

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2014
    Posts
    24

    Unhappy problem with compare the value of textbox with datatable rows

    Hello there,

    I have a problem with the following code; it executes two instructions simultaneously

    for i=0 to dt.rows.count -1
    if dt.rows(i).item("CIN").valuetostring=textbox1.text
    message.show("deja existe")
    else
    form2.show
    next i

    I try with i = i +1 and exit for before else but when if is true they do if and else is the same time

  2. #2
    Hyperactive Member
    Join Date
    Jun 2014
    Location
    Lahore, Pakistan
    Posts
    450

    Re: problem with compare the value of textbox with datatable rows

    Quote Originally Posted by karimi94 View Post
    Hello there,

    I have a problem with the following code; it executes two instructions simultaneously

    for i=0 to dt.rows.count -1
    if dt.rows(i).item("CIN").valuetostring=textbox1.text
    message.show("deja existe")
    else
    form2.show
    next i

    I try with i = i +1 and exit for before else but when if is true they do if and else is the same time
    Try this way:

    Code:
    for i=0 to dt.rows.count -1 
    if dt.rows(i).item("CIN").valuetostring=textbox1.text 
    message.show("deja existe")
    exit sub
    elseif dt.rows(i).item("CIN").valuetostring<>textbox1.text 
    form2.show 
    exit sub
    next i
    Last edited by hamza.saleem; Jul 19th, 2014 at 09:09 AM.

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: problem with compare the value of textbox with datatable rows

    for i=0 to dt.rows.count -1
    if dt.rows(i).item("CIN").valuetostring=textbox1.text
    message.show("deja existe")
    else
    form2.show
    next i

    that says, for every row that the CIN field = textbox1.text, show a msgbox. for all rows where it is inequal show Form2

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