Hello All,

Can someone please help me with this? I converted from C# to VB.NET and get this error :

A namespace cannot directly contain members such as fields or methods


I appreciate you looking at this.

Regards


Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Namespace UsedCarsSales
Public NotInheritable Class Calculations
Private Sub New()
End Sub
Private Shared pack As Decimal = 300

Public Shared Function getTotalSales() As Decimal
Dim sales As New Sales()
Return sales.SellingPrice
End Function

Public Shared Function getNetProfit(acquisitionCost As Decimal, sellingPrice As Decimal, maintainanceCost As Decimal) As Decimal
Return sellingPrice - (acquisitionCost + maintainanceCost + pack)

End Function

End Class
End Namespace

Recommended Answers

All 9 Replies

By copy/pasting into VS and creating my own dummy class of Sales I managed to get it working.

Perhaps something wrong with other code in the same .vb file?

By copy/pasting into VS and creating my own dummy class of Sales I managed to get it working.

Perhaps something wrong with other code in the same .vb file?

I don't know what the problem could likely be. I have other files in the project and maybe it is. Please do you have an idea of how best i can approach it?

I could zip up the files but i can't even post it on here.

What you posted is EVERYTHING out of the single vb file? If so, I would check for some rogue characters outside the namespace/end namespace

What you posted is EVERYTHING out of the single vb file? If so, I would check for some rogue characters outside the namespace/end namespace

No, i just posted one of the files in the project. I have more files on there. Hmm let me do that.I have been trying to sort this out for the past 12hrs.Thank you so much for your swift response. I appreciate it.

No problem at all friend. I hope you find the solution to your problem.

No problem at all friend. I hope you find the solution to your problem.

Yeah i hope so too. Taking me so much time and am new to this.

No problem at all friend. I hope you find the solution to your problem.

Friend, can you help me make sense of this please ?

Public Event CheckedChanged(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

Code : Me.radioButtonLastName.AutoSize = True
Me.radioButtonLastName.Location = New System.Drawing.Point(5, 19)
Me.radioButtonLastName.Name = "radioButtonLastName"
Me.radioButtonLastName.Size = New System.Drawing.Size(73, 17)
Me.radioButtonLastName.TabIndex = 8
Me.radioButtonLastName.TabStop = True
Me.radioButtonLastName.Text = "LastName"
Me.radioButtonLastName.UseVisualStyleBackColor = True
Me.radioButtonLastName.CheckedChanged += New System.EventHandler(AddressOf Me.radioButtonLastName_CheckedChanged)
'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.