Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vb.net radio buttons - error BC30205: End of statement expected

Posted on 2014-07-29
6
Medium Priority
?
638 Views
Last Modified: 2014-08-05
Hi,

I'm looking for some help with my if statements within a script.  In a simple format,  

if Radio Button 1 is clicked do x
if Radio Button 2 is clicked do y
Else "Please select x or y"

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs)

		Dim fname
		
			If Radiobutton1.Checked True Then
			fname = Request.QueryString("TextBox1.Text")
				
				If fname <> ("") Then
					Dim objFSO, strFolder
						objFSO = CreateObject("Scripting.FileSystemObject")
						strFolder = "d:\Check\TESTX\" 
				
						If 	objFSO.FolderExists(strFolder) = True Then
							StatusLabel.Text = "Folder already exists"
						ELSE
							objFSO.CreateFolder(strFolder)
							StatusLabel.Text = "Cool Option X Selected<br>"
					End If
				End If
			Else
			StatusLabel.Text = "Please Answer Yes or No"
		End If
			
				If Radiobutton2.Checked True Then
				fname = Request.QueryString("TextBox1.Text")
				
				If fname <> ("") Then
					Dim objFSO, strFolder
						objFSO = CreateObject("Scripting.FileSystemObject")
						strFolder = "d:\CHECK\TESTY\" 
				
						If 	objFSO.FolderExists(strFolder) = True Then
							StatusLabel.Text = "Folder already exists"
						ELSE
							objFSO.CreateFolder(strFolder)
							StatusLabel.Text = "Cool Option Y Selected<br>"
					End If
				End If
			Else
			StatusLabel.Text = "Please Answer X or Y"
		End If
	End Sub
End Class

Open in new window

0
Comment
Question by:patelbg2001
[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
  • 4
6 Comments
 
LVL 21

Expert Comment

by:Randy Poole
ID: 40226352
Partial Class _Default Inherits System.Web.UI.Page  
  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

		Dim fname
		If Radiobutton1.Checked True Then
			fname = Request.QueryString("TextBox1.Text")
			If fname <> ("") Then
  			Dim objFSO, strFolder
				objFSO = CreateObject("Scripting.FileSystemObject")
				strFolder = "d:\Check\TESTX\" 
							
				If 	objFSO.FolderExists(strFolder) = True Then
				  StatusLabel.Text = "Folder already exists"
				ELSE
					objFSO.CreateFolder(strFolder)
					StatusLabel.Text = "Cool Option X Selected<br>"
				End If
			Else
  			StatusLabel.Text = "Please Answer Yes or No"
  		end if
  	end if			
		If Radiobutton2.Checked True Then
		  fname = Request.QueryString("TextBox1.Text")
			If fname <> ("") Then
			  Dim objFSO, strFolder
				objFSO = CreateObject("Scripting.FileSystemObject")
				strFolder = "d:\CHECK\TESTY\" 
				If objFSO.FolderExists(strFolder) = True Then
				  StatusLabel.Text = "Folder already exists"
				ELSE
				  objFSO.CreateFolder(strFolder)
					StatusLabel.Text = "Cool Option Y Selected<br>"
				End If
			Else
  			StatusLabel.Text = "Please Answer X or Y"
	  	End If
	  end If
End Sub
End Class

Open in new window

0
 
LVL 6

Author Comment

by:patelbg2001
ID: 40231269
I recieve a compilation error using the suggested code above.

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Source Error:

Line 1:  Partial Class _Default Inherits System.Web.UI.Page  
Line 2:    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Line 3:    
 
Source File: D:\pstupload\Default.aspx.vb    Line: 1
0
 
LVL 15

Expert Comment

by:rajeeshmca
ID: 40231564
Hi,

I hope you are missing an "=" in the following statement

If Radiobutton1.Checked True Then

Try changing it to

If Radiobutton1.Checked = True Then
    Something
Else
    Something

Regards
Rajeesh
0
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
LVL 6

Author Comment

by:patelbg2001
ID: 40231583
I've simplfied what the logic shoukd look like. I can browse to the page fine now.
All I wanted was if the text box has an entry and button1 or 2 is selected the boolean value is true.. If just the test box is select then ask for yes or no selection etc....

does the code logic look ok?



Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs)
		
		Dim fname
		fname = Request.QueryString("TextBox1.Text")
		
		Dim ButtonYes As Boolean = False
        Dim ButtonNo As Boolean = False
		Dim Name As Boolean = False
		Dim abc As Boolean = False
		Dim def As Boolean = False
                                   Dim ghi As Boolean = False
	
			If fname <> "" Then Name = True
			If RadioButton1.Checked Then ButtonYes = True
			If RadioButton2.Checked Then ButtonNo = True
	
	IF Name and ButtonYes Then
		abc = True
		StatusLabel.Text = "Yes"
	ELSEIF Name and ButtonNo Then
		def = True
		StatusLabel.Text = "No"
	ELSEIF Name Then
		ghi = True
		StatusLabel.Text = "Please Confirm Yes or No"
	ELSE
		StatusLabel.Text = "Please enter Name"
	End If

End Sub
End Class

Open in new window

0
 
LVL 6

Accepted Solution

by:
patelbg2001 earned 0 total points
ID: 40232013
I solved it myself. Thanks
0
 
LVL 6

Author Closing Comment

by:patelbg2001
ID: 40240774
I found that with radio buttons and statments cannot be used, only boolean (Yes/No)
0

Featured Post

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

722 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