Solved

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

Posted on 2014-07-29
6
562 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
  • 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

810 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