473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

declaration expected was unexpected



Trying to learn OOP. Pasted some MS example code inside a form class(but of
course made the test class outside of the form class);

I get "declaration epected" pointing to"Currentsale" ; this is the same
error I get with my own test code....

Dim CurrentSale As New SalesRecord

CurrentSale.CustomerName = "Matthew"

Public Class SalesRecord

Private _CustomerName As String

Private _Total As Decimal

Public Property CustomerName() As String

Get

Return _CustomerName

End Get

Set(ByVal Value As String)

_CustomerName = Value

End Set

End Property

Public Property Total() As Decimal

Get

Return _Total

End Get

Set(ByVal Value As Decimal)

If Value >= 0 Then

_Total = Value

Else

' Raise an error here.

End If

End Set

End Property

Public Function EstimateLatePaymentCost(ByVal _

YearsLate As Single) As Decimal

' Assuming 5%/year late payment fee.

Return (_Total * (1 + YearsLate * 0.05))

End Function

End Class
Nov 21 '05 #1
5 2776
"baret bonden" <ar****@networks-cc.com> schrieb:
Trying to learn OOP. Pasted some MS example code
inside a form class(but of course made the test class
outside of the form class);

I get "declaration epected" pointing to"Currentsale" ; this is the same
error I get with my own test code....

Dim CurrentSale As New SalesRecord

CurrentSale.CustomerName = "Matthew"


Where did you place this code?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2
I put the class at the end of a windows form, outside the form's class , and
I put the

Dim CurrentSale As New SalesRecord
CurrentSale.CustomerName = "Matthew"

simply inside the form's clode
as in:

Public Class test

Inherits System.Windows.Forms.Form

dim CurrentSale As New SalesRecord

CurrentSale.CustomerName = "Matthew"
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ed*************@TK2MSFTNGP11.phx.gbl...
"baret bonden" <ar****@networks-cc.com> schrieb:
Trying to learn OOP. Pasted some MS example code
inside a form class(but of course made the test class
outside of the form class);

I get "declaration epected" pointing to"Currentsale" ; this is the same
error I get with my own test code....

Dim CurrentSale As New SalesRecord

CurrentSale.CustomerName = "Matthew"


Where did you place this code?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #3

"baret bonden" <ar****@networks-cc.com> wrote
in message news:2u*************@uni-berlin.de...

Public Class test

Inherits System.Windows.Forms.Form

dim CurrentSale As New SalesRecord

CurrentSale.CustomerName = "Matthew"


Executable code has to be placed in a procedure. You need
to place that last line in a Sub or Function....

LFS
Nov 21 '05 #4
"baret bonden" <ar****@networks-cc.com> schrieb:
I put the class at the end of a windows form, outside the form's class , and

That's OK.
I put the

Dim CurrentSale As New SalesRecord
CurrentSale.CustomerName = "Matthew"

simply inside the form's clode
as in:

Public Class test

Inherits System.Windows.Forms.Form

dim CurrentSale As New SalesRecord

CurrentSale.CustomerName = "Matthew"


You will have to put the code into a procedure (at least the 2nd line), for
example (inside your class):

\\\
Public Sub Foo()
Dim CurrentSale As New SalesRecord()
CurrentSale.CustomerName = "Matthew"
...
End Sub
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #5
Got it; works fine; many thanks !
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:#n**************@TK2MSFTNGP14.phx.gbl...
"baret bonden" <ar****@networks-cc.com> schrieb:
I put the class at the end of a windows form, outside the form's class , and

That's OK.
I put the

Dim CurrentSale As New SalesRecord
CurrentSale.CustomerName = "Matthew"

simply inside the form's clode
as in:

Public Class test

Inherits System.Windows.Forms.Form

dim CurrentSale As New SalesRecord

CurrentSale.CustomerName = "Matthew"


You will have to put the code into a procedure (at least the 2nd line),

for example (inside your class):

\\\
Public Sub Foo()
Dim CurrentSale As New SalesRecord()
CurrentSale.CustomerName = "Matthew"
...
End Sub
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SaCompGeek | last post by:
I have a class that defines a Key/Name value collection that i generated by and XML Element with multiple attributes. The attribute are used to create the collection of 'Binate' objects. This is...
6
by: Sakcee | last post by:
html = '<html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <head></head> <body bgcolor=#ffffff>\r\n Foo foo , blah blah </body></html>' >>> import htmllib >>> import...
2
by: P | last post by:
Hi all, I'm trying to run the following code taken from http://blogs.ittoolbox.com/database/technology/archives/006045.asp# select substr(tablespace_name,1,30) as "Tablespace Name", case...
1
by: Ben Walling | last post by:
I'm getting the following error on one of 110 machines that is using a webservice to upload database changes to a central location: System.Web.Services Server was unable to read request. --There...
7
by: Florian Haag | last post by:
Hello, I'm trying to compile a programme which compiles fine under Linux; I'm trying it with MinGW G++ 3.4.2: Component.h: #ifndef COMPONENT_H_ #define COMPONENT_H_
2
by: =?Utf-8?B?Y2FzaGRlc2ttYWM=?= | last post by:
Hi, has anyone come across this error before: This is an unexpected token. The expected token is 'NAME' I am getting it when trying to send an xml file across a web service layer. The...
8
by: aneuryzma | last post by:
Hello, I'm merging an OpenCV app with an Ogre3d app. I'm on a mac, I'm using xCode. When I add #include "openCVApp.h" I got the following error:
6
by: samsneelam | last post by:
Hi.. This is samuel, while doing a program, i encountered this problem.. Let me give you clarity regarding my prob.. I am having two files .. one is mpcplib.h it contains the follwing...
1
by: shekhardotnet | last post by:
below testing code gives an error "declaration expected" please suggest Imports System.Data.SqlClient Public Class Form1 Inherits System.Windows.Forms.Form 'Create ADO.NET objects....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.