Solved

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

Posted on 2014-07-29
6
582 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

763 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