Public Property Expresion Expected
Public Property Expresion Expected
Public Property Expresion Expected
Public Property Expresion Expected
Public Property Expresion Expected
Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected
Public Property Expresion Expected Public Property Expresion Expected
Public Property Expresion Expected
Go Back  Xtreme Visual Basic Talk > > > Public Property Expresion Expected


Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2017, 08:14 AM
JeremyBenson11 JeremyBenson11 is offline
Regular
 
Join Date: Dec 2013
Posts: 50
Default Public Property Expresion Expected


Hello,

I'm getting an error expression expected when trying to set a public property, but can't seem to find the error. Thanks for reading.

Class
Code:
Public Class World
	Public Property currentRoom() As String
		Get
			Return Me.currentRoom
		End Get
		Set(ByVal value As String)
			Me.currentRoom = value
		End Set
	End Property
	Public Property currentRegion() As String
		Get
			Return Me.currentRegion
		End Get
		Set(ByVal value As String)
			Me.currentRegion = value
		End Set
	End Property
End Class
Program
Code:
Module Program
	Sub Main()
		Dim world As World = New World()
		world.currentRoom = 'Bedroom'
		Console.Write("Press any key to continue . . . ")
		Console.ReadKey(True)
	End Sub
End Module
Reply With Quote
  #2  
Old 08-16-2017, 08:20 AM
Goggy's Avatar
Goggy Goggy is offline
Contributor
 
Join Date: Sep 2005
Location: Enschede,The Netherlands
Posts: 670
Default

both your properties are recursively setting them self.

Code:
Public Property X() As String 
		Get
			Return Me.X
		End Get
		Set(ByVal value As String)
			Me.X = value
		End Set
	End Property
To sove this, try some thing like the following


Code:
Private m_X as String 

Public Property X() As String 
		Get
			Return Me.m_X
		End Get
		Set(ByVal value As String)
			Me.m_X = value
		End Set
	End Property
__________________
As finishing touch, god created the Dutch!

utterly useless, but always trying to help
Reply With Quote
  #3  
Old 08-16-2017, 10:00 AM
JeremyBenson11 JeremyBenson11 is offline
Regular
 
Join Date: Dec 2013
Posts: 50
Default

Still getting the same error, I added to lines to my main program, and both are getting the error. Maybe some kind of typo?

Code:
Public Class World
	Private currentRoom As String
	Private currentRegion As String
	Public Property room() As String
		Get
			Return Me.currentRoom
		End Get
		Set(ByVal value As String)
			Me.currentRoom = value
		End Set
	End Property
	Public Property region() As String
		Get
			Return Me.currentRegion
		End Get
		Set(ByVal value As String)
			Me.currentRegion = value
		End Set
	End Property
End Class
Code:
Module Program
	Sub Main()
		Dim world As World = New World()
		world.room = 'Bedooroom'
		world.region = 'Alm'
		Console.Write("Press any key to continue . . . ")
		Console.ReadKey(True)
	End Sub
End Module
Reply With Quote
  #4  
Old 08-16-2017, 11:20 AM
Goggy's Avatar
Goggy Goggy is offline
Contributor
 
Join Date: Sep 2005
Location: Enschede,The Netherlands
Posts: 670
Post

world.room = 'Bedooroom'
world.region = 'Alm'

Here's the typo, vb doesn't use single quotes for a a string but double, like so...

Code:
        world.room = "Bedooroom"
        world.region = "Alm"
__________________
As finishing touch, god created the Dutch!

utterly useless, but always trying to help
Reply With Quote
Reply

Tags
property, public, string, world, class, set, setbyval, error, me.currentroom, expected, program, module, me.currentregion, return, dim, main, world.currentroom, bedroom, continue, console.readkeytrue, key, console.writepress, currentregion, currentroom, reading


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Public Property Expresion Expected
Public Property Expresion Expected
Public Property Expresion Expected Public Property Expresion Expected
Public Property Expresion Expected
Public Property Expresion Expected
Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected Public Property Expresion Expected
Public Property Expresion Expected
Public Property Expresion Expected
 
Public Property Expresion Expected
Public Property Expresion Expected
 
-->