Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to VB.NET, creating my first Class

Status
Not open for further replies.

traceytr

Programmer
Mar 13, 2001
94
US
Hi. I’m a VB6 coder (intermediate level,) but very rusty after 22 months of software support and no new development. I’m totally new to VB.NET, and after all this time I’m expected to hit the ground running using VB.NET. No crawling before walking, walking before running, etc.

I have some logic behind a form (for now,) that does pretty much what I want it to. The logic can’t stay in the form, though, because I don’t need a user interface. Ultimately, I need to put the logic into a Class where I can call it from a Windows Service (which has yet to be created, but that's another topic for another day.)

Okay, don’t laugh now… I created the Class and copied over some of the logic. Oh my gosh… Errors GALORE! I’ve pasted the offending code below only up to the point of the first error. The last line of this code is strFileDate = strDate. I’m getting the squiggly line under strFileDate to let me know VB.NET doesn’t like it. When I hover over strFileDate, the tip says “Declaration expected.” Can someone explain to me what I’m doing wrong here? Thanks.


Public Class MyClass
Dim strFileDate As String
Dim strDate As String = Mid(CStr(Now), 1, 10)
strFileDate = strDate



Tracey
 
>> strFileDate = strDate

You can only declare variables in a class. To do the above assignment, you must write in in a code block... like sub, function, property.. etc
 
Amazing how all the squiggly lines disappeared, well all but a couple. Thanks!

Tracey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top