473,546 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "declaratio n epected" pointing to"Currentsal e" ; this is the same
error I get with my own test code....

Dim CurrentSale As New SalesRecord

CurrentSale.Cus tomerName = "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 EstimateLatePay mentCost(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 2786
"baret bonden" <ar****@network s-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 "declaratio n epected" pointing to"Currentsal e" ; this is the same
error I get with my own test code....

Dim CurrentSale As New SalesRecord

CurrentSale.Cus tomerName = "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.Cus tomerName = "Matthew"

simply inside the form's clode
as in:

Public Class test

Inherits System.Windows. Forms.Form

dim CurrentSale As New SalesRecord

CurrentSale.Cus tomerName = "Matthew"
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ed******** *****@TK2MSFTNG P11.phx.gbl...
"baret bonden" <ar****@network s-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 "declaratio n epected" pointing to"Currentsal e" ; this is the same
error I get with my own test code....

Dim CurrentSale As New SalesRecord

CurrentSale.Cus tomerName = "Matthew"


Where did you place this code?

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

Nov 21 '05 #3

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

Public Class test

Inherits System.Windows. Forms.Form

dim CurrentSale As New SalesRecord

CurrentSale.Cus tomerName = "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****@network s-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.Cus tomerName = "Matthew"

simply inside the form's clode
as in:

Public Class test

Inherits System.Windows. Forms.Form

dim CurrentSale As New SalesRecord

CurrentSale.Cus tomerName = "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.Cus tomerName = "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******** ******@TK2MSFTN GP14.phx.gbl...
"baret bonden" <ar****@network s-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.Cus tomerName = "Matthew"

simply inside the form's clode
as in:

Public Class test

Inherits System.Windows. Forms.Form

dim CurrentSale As New SalesRecord

CurrentSale.Cus tomerName = "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.Cus tomerName = "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
16277
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 writte in VB.NET 1.1. I have this class in a Win32 test application and it works fine. Whe I put the class in a Web app I get the following...
6
3078
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 formatter >>> parser=htmllib.HTMLParser(formatter.NullFormatter()) >>> parser.feed(html)
2
19961
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 (tablespace_type) when 0 then 'DMS' else 'SMS' end as "Type",
1
2939
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 is an error in XML document (3, 2148906). --This is an unexpected token. The expected token is 'NAME'. Line 3, position 2148909. at...
7
9422
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
3120
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 xml file is well formed, having been checked with XmlSpy. The size of the file is roughly 119KB. I think it was written in MS Word and the HTML is
8
7859
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
14710
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 declerations.... #include <queue> #include <vector> #include <string> class database { queue<delayTP> delayThrouput;
1
2640
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. Private myConn As SqlConnection Private myCmd As SqlCommand
0
7435
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7698
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5361
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1922
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.