CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Apr 2004
    Posts
    158

    Where has the subroutine gone?

    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.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Where has the subroutine gone?

    You simply type.

    Code:
    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.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Apr 2004
    Posts
    158

    Re: Where has the subroutine gone?

    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.

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Where has the subroutine gone?

    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.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Where has the subroutine gone?

    If you download VS2010, you NEED this:

    http://www.devexpress.com/Products/V...-in/CodeRushX/
    Attached Images Attached Images  
    Last edited by dglienna; May 9th, 2010 at 12:24 PM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Apr 2004
    Posts
    158

    Re: Where has the subroutine gone?

    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.

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Where has the subroutine gone?

    Can you show us the code?

  8. #8
    Join Date
    Dec 2007
    Posts
    234

    Re: Where has the subroutine gone?

    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.

    -tg
    * I don't respond to private requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help - how to remove eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to???
    * On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming.
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
    MVP '06-'10

  9. #9
    Join Date
    Apr 2004
    Posts
    158

    Re: Where has the subroutine gone?

    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.

  10. #10
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    Re: Where has the subroutine gone?

    Quote Originally Posted by dajunka View Post
    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.
    [Vb.NET 2008 (ex Express)]

  11. #11
    Join Date
    Apr 2004
    Posts
    158

    Re: Where has the subroutine gone?

    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.

  12. #12
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    Re: Where has the subroutine gone?

    Quote Originally Posted by dajunka View Post
    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.
    [Vb.NET 2008 (ex Express)]

  13. #13
    Join Date
    Dec 2007
    Posts
    234

    Re: Where has the subroutine gone?

    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...

    -tg
    * I don't respond to private requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help - how to remove eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to???
    * On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming.
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
    MVP '06-'10

  14. #14
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Where has the subroutine gone?

    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.
    Always use [code][/code] tags when posting code.

  15. #15
    Join Date
    Dec 2007
    Posts
    234

    Re: Where has the subroutine gone?

    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)

    -tg
    * I don't respond to private requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help - how to remove eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to???
    * On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming.
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
    MVP '06-'10

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured