Solved

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

Posted on 2014-07-29
6
615 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

630 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