I am trying to get the hang of this stupid VB.net, but it won't even let me create a subroutine or function, it use to be in the tools menu in VB6. Can anyone tell me where it's hiding?
I have spent £50 on 2 books that rabbit on about objects, property's classes etc: but tell me nothing of what I want/need to know, what a waste of money.
Last edited by dajunka; May 9th, 2010 at 06:47 AM.
Private Sub MySub(MyData as string)
'your code
End Sub
'or
Private Function MyFunction(MyData as string) as string
'your code
return somestring
End Function
I do not know about the menus as I never used the menu to add a sub or function in VB at any point. I've always typed them in and they have pretty much remained the same as always.
The only real difference is that you use the Return keyword in functions now where in previous versions you would use the function name = to return a value.
Return also causes the code to exit the function when that line is executed.
Thank you for that.
Looks like I will have to enter it manually too. I can't believe that the coders of this new VB forgot to include a menu option for what is a heavily used part of vb.
Up to now this whole vb net thing feels a little rushed and not very well thought out, I wish they had kept support for VB6.
I do not know how heavily it is used. I've been using VB professionally for going on 15 years and have never used it even once. Can't say that I've ever saw anyone else use it either. It is good for beginers but for most of us it is faster and easier to just type it.
This net thing is so flipping frustrating, it's so hard to get anything to work with it.
I made a sub routine as I was shown, and placed my load data routine into it that I know works perfectly, but even though I call the routine nothing happens. I just don't understand it.
Neither do I... but then I'm not clairvoyant, so I don't know what your code looks like. Post your code (be sure to use the proper code tags around it) and we'll see if we can spot the problem.
So sorry. I found out what happened.
With my experiments with loading and saving data somehow my data file had been empted, the file was still there but was minus all it's data, and that's why my sub routine wasn't returning anything.
I use VB.Net 2008 in all my wash, for those whiter whites.
This net thing is so flipping frustrating, it's so hard to get anything to work with it.
I made a sub routine as I was shown, and placed my load data routine into it that I know works perfectly, but even though I call the routine nothing happens. I just don't understand it.
I also switched from VB6 to VB.net time ago, and was frustrated at start.
But I'm Happy with the switch. VB.NET is much better. Far, far, far better.
It's another level. It have little, if anything, to envy to C++. You can do serious code with VB.NET.
Hope you enjoy it, and ask for help, if you need it.
Well, I have just finished my first little program and it works really well.
It was a lot of hard and frustrating work, and a few times I nearly gave up.
Now I have cracked the surface it should get a little easier, I know I am actually starting to enjoy myself now rather than wanting to kill my computer.
I use VB.Net 2008 in all my wash, for those whiter whites.
I am trying to get the hang of this stupid VB.net, but it won't even let me create a subroutine or function, it use to be in the tools menu in VB6. Can anyone tell me where it's hiding?
I have spent £50 on 2 books that rabbit on about objects, property's classes etc: but tell me nothing of what I want/need to know, what a waste of money.
I forgot the answer!
to get the function skeleton, and lots of other constructs, just rigth click on the place, click
Insert snippet>Code Patterns - If, For Each....>Properties, Procedures, Events>Define a function
and the skeleton of a function will appear.
That is more useful to other code patterns, like Properties.
Properties is problably the easiest structure to insert. type "prop" press TAB twice... the first will fill in "property" the second will insert the property snippet. From there you just need to fill in the fields... pressing tab to cycle between each one.
Same thing with functions (type "func") and subs (only need to press TAB once after sub....)
For read only properties, try "propread" TAB TAB...
hmm I was not aware of this but it really does not seem to be much of a help from a coding standpoint. Properties seem to default to private so that needs to be changed most of the time, just typing prop does not work on my system so I still have to type the full word property to get the skeleton.
Looks like the only thing it does for me is adds the () , the return and =value. I think it is just as fast to just type it as usual because after you type the first line and hit enter the frame is created for you then you just need to write code in the get and set areas.
Same is true for sub and function, you still need to type sub or function func does not work on my system. In both cases it omits the private, public or whatever and in the case of a function sets the return to integer. Given this in most cases you will still have to type the same thing but you have to skip around to do it rather than just straight up typing.
I guess if that is what you like it is ok but for me it is much faster to just type it and be done.
I didn't say I like it... I just stated it as an option... I wonder why prop and func don't work for you... (prop and property both default to Public for me.... not sure why yours would default private as a private property is kinda useless). More often than not, I type "Public Property {property name} as {type} and press enter and get what I need... except in VS2010... where I get auto implemented properties (That right there is a major bonus for me... I've got Excel macros that I can use now to generate my table scripts for SQL, AND properties for VB all in one go... I'm spoiled)
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.