Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 15-05-2010, 11:33 AM   #1 (permalink)
Right Off the Assembly Line
 
deepakgates's Avatar
 
Join Date: May 2008
Location: Home
Posts: 36
Angry radio button checked and not checked at same time


okay then ....
im making dynamic sql statement
rmode is a radio button and tmode is a combo box



Quote:
Private Sub bsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bsearch.Click

If rmode.Checked = True Then
ElseIf tmode.SelectedIndex = 0 Then
sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
ElseIf tmode.SelectedIndex = 1 Then
sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
End If



If rmode.Checked = True Then
MsgBox("mode")

End If






con.Open()
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "licdb")
con.Close()
datagridresult.DataSource = ds.Tables("licdb").DefaultView
End Sub

im facing a hell of a problem
do u see two if statement
just one get executed

the second one... if i put only second then it gets executed and if only first then nothing gets executed..

WHYYYYYYYYYYYYYYYY????

PS: radiobutton is checked!!
deepakgates is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 15-05-2010, 11:14 PM   #2 (permalink)
Alpha Geek
 
Join Date: Jan 2007
Location: In your hearts
Posts: 828
Default Re: radio button checked and not checked at same time

instead of elseif try to use nested if and tell the results here.
i guess u are using vb2005 or later.
abhijangda is offline  
Old 16-05-2010, 09:42 AM   #3 (permalink)
Right Off the Assembly Line
 
deepakgates's Avatar
 
Join Date: May 2008
Location: Home
Posts: 36
Thumbs up Re: radio button checked and not checked at same time

You are a genius....
You did it

It worked

But please tell me why it worked and what was the problem earlier...i want to know!!


am using vs2008
deepakgates is offline  
Old 16-05-2010, 09:48 AM   #4 (permalink)
In The Zone
 
ruturaj3's Avatar
 
Join Date: Feb 2007
Location: Mumbai
Posts: 214
Default Re: radio button checked and not checked at same time

try this,

If rmode.Checked = True Then

If tmode.SelectedIndex = 0 Then
sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
End If
If tmode.SelectedIndex = 1 Then
sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
End If

End If
ruturaj3 is offline  
Old 16-05-2010, 10:17 AM   #5 (permalink)
Right Off the Assembly Line
 
deepakgates's Avatar
 
Join Date: May 2008
Location: Home
Posts: 36
Default Re: radio button checked and not checked at same time

ya it worked

now please tell me how what is the difference!!
deepakgates is offline  
Old 16-05-2010, 03:57 PM   #6 (permalink)
Alpha Geek
 
Join Date: Jan 2007
Location: In your hearts
Posts: 828
Default Re: radio button checked and not checked at same time

Quote:
Originally Posted by deepakgates View Post
You are a genius....
You did it

It worked

But please tell me why it worked and what was the problem earlier...i want to know!!


am using vs2008
it is simple dude
u said that radio button is selected.
But in IF command u use ELSEIF
which will be executed only when radio button is not selected. that's why.
thx for calling me genius.
abhijangda is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:17 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2