Solved

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

Posted on 2014-07-29
6
536 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Author Comment

by:patelbg2001
Comment Utility
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
Comment Utility
I solved it myself. Thanks
0
 
LVL 6

Author Closing Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now