Results 1 to 15 of 15

Thread: Code Missing but form still runs... How can that be possible

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2013
    Posts
    292

    Code Missing but form still runs... How can that be possible

    VS2013 Community.

    One of my forms seems to have lost all the vb code except form_load code...but it still runs...***?

    This is all the code that shows in formname.vb

    Code:
    Public Class configurations
    
       
        Private Sub configurations_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        End Sub
    End Class
    The form displays just fine. All the text boxes are there. It's getting data sent to three text boxes from the main form...and they work. I can view code in the form designer as well... HELP...what do I look for...how do I correct this.

    This was developed in VB2010 Express and recently been worked on in VS2013 Community... but all the forms have been opened and most modified since the version change about 2 weeks ago.

    Until I ran a performance evaluation on the code in 2013 Community, The .sln icon still showed 2010 version and I could go back and forth if I wanted to. I can't do that since running that performance evaluation thing. It changed the .sln icon to 12 on me.
    Last edited by larrycav; Dec 15th, 2014 at 09:17 PM.

  2. #2
    Fanatic Member Toph's Avatar
    Join Date
    Oct 2014
    Posts
    655

    Re: Code Missing but form still runs... How can that be possible

    Clean your source, rebuild, clean your solution and rebuild and tell me what happens after that

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,956

    Re: Code Missing but form still runs... How can that be possible

    In the Solution Explorer, there's a button "Show all files" ... click it... you'll see a plus or triangle next to your form... click it... you should then see a formname.designer.vb ... that's what is known as the designer file... in it you'll find all the code that builds the form. Except for some verrrrrrrrrry extreme cases, you should never touch the code in there, as it gets re-written by the ide when you make changes to your form. All of your code should be in the formname.vb file... that's yours to muck about as you please.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing 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??? *

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2013
    Posts
    292

    Re: Code Missing but form still runs... How can that be possible

    Quote Originally Posted by Toph View Post
    Clean your source, rebuild, clean your solution and rebuild and tell me what happens after that
    You'll have to excuse my lack of experience... Are there built in tools for those two operations?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2013
    Posts
    292

    Re: Code Missing but form still runs... How can that be possible

    Quote Originally Posted by techgnome View Post
    In the Solution Explorer, there's a button "Show all files" ... click it... you'll see a plus or triangle next to your form... click it... you should then see a formname.designer.vb ... that's what is known as the designer file... in it you'll find all the code that builds the form. Except for some verrrrrrrrrry extreme cases, you should never touch the code in there, as it gets re-written by the ide when you make changes to your form. All of your code should be in the formname.vb file... that's yours to muck about as you please.

    -tg
    I knew about the designer, the vb and the resx files. I don't recall ever having touched the code in the designer. I have viewed it before...

    I don't know how to clean the source or do a rebuild. Can you explain? I assume there are tools within VS for those chores perhaps?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2013
    Posts
    292

    Re: Code Missing but form still runs... How can that be possible

    I found what I think are the correct tools in the build menu. Have never used them before... I'll see what happens... thanks guys.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2013
    Posts
    292

    Re: Code Missing but form still runs... How can that be possible

    I ran both rebuild and clean.... didn't have any effect on the issue.

  8. #8
    New Member
    Join Date
    Jul 2014
    Posts
    13

    Re: Code Missing but form still runs... How can that be possible

    just delete everything here "\obj\Release" then click build again

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,242

    Re: Code Missing but form still runs... How can that be possible

    Well, let's cover the obvious question first: Was there something more in the code file than what you just showed at some earlier time?

    It's no surprise that the designer still works if the .designer.vb file is still there. Other than that, something quite strange is happening. It used to be fairly easy to get a disconnect between the code you are seeing and the code that the IDE is running. All you had to do was get one setting wrong, but that hasn't been the default behavior for many versions (not since 2003, I think), so getting the setting wrong would mean taking action in the Options. Still, that wouldn't account for all the code disappearing, which is why I just wanted to be sure that there actually WAS more code in the file.
    My usual boring signature: Nothing

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,956

    Re: Code Missing but form still runs... How can that be possible

    I wonder if maybe it got moved off into a partial class elsewhere.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing 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??? *

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2013
    Posts
    292

    Re: Code Missing but form still runs... How can that be possible

    Quote Originally Posted by Shaggy Hiker View Post
    Well, let's cover the obvious question first: Was there something more in the code file than what you just showed at some earlier time?

    It's no surprise that the designer still works if the .designer.vb file is still there. Other than that, something quite strange is happening. It used to be fairly easy to get a disconnect between the code you are seeing and the code that the IDE is running. All you had to do was get one setting wrong, but that hasn't been the default behavior for many versions (not since 2003, I think), so getting the setting wrong would mean taking action in the Options. Still, that wouldn't account for all the code disappearing, which is why I just wanted to be sure that there actually WAS more code in the file.
    Yes there are textboxes groupboxes...etc. and I actually discovered that the version change didn't cause it.

    As I progressed through the project, I saved my work as versions of the project. I went back to early versions of that form and the same darn thing happens. The forum runs, the designer code is there but the written vb code is NOT... So it happened in VS2010 Express. That particular form was built very early on and not touched for a few months now. I didn't even know there was a problem until today when I went to add something to the form and saw the code was gone...

    Is there a way to use the designer code to regenerate the vb code?

  12. #12
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,548

    Re: Code Missing but form still runs... How can that be possible

    Yes there are textboxes groupboxes...etc.
    that doesn't mean there was any code in the form class. Give us an example of what code you wrote and expected to find.

  13. #13
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,242

    Re: Code Missing but form still runs... How can that be possible

    I agree with wes4dbt. All the control creation, positioning, and property settings are found in the .designer.vb file. What is in the other file is all the code that you wrote by hand.

    I haven't used VS2013, yet, so I don't know if they did something differently, but there is nothing that states that any particular code has to be located in any particular file. Prior to VS2005, ALL the code was found in just one file because partial classes hadn't been introduced, yet. Starting with VS2005 and the advent of partial classes, MS moved the designer code into a partial class found in the .designer.vb file so that it would be out of sight/out of mind. There's no rule about that. Those partial classes all get recombined for compilation. You can write all that designer code in one file and not use a .designer.vb file at all, if you want. I have an app written like that (it was written largely by a generator). The designer has no problem with that, either.

    So, one alternative possibility is that the code was just moved into another partial class such that the code for the file is spread across three or more files. Some people even advocate doing something like that. Without knowing VS2013, I don't know whether or not MS didn't decide to change the organization of the files in some new way (though I haven't heard of anything of the sort). If you are showing all files in Solution Explorer, are there any files associated with the form that you don't immediately recognize?
    My usual boring signature: Nothing

  14. #14
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,781

    Re: Code Missing but form still runs... How can that be possible

    Quote Originally Posted by larrycav View Post
    It's getting data sent to three text boxes from the main form...and they work. I can view code in the form designer as well... HELP...what do I look for...how do I correct this.
    To add, the data being sent, could be in a few different ways. If your mainform directly sets the values of the UI, then no code would need be present in the form and it would still work. If you are actually calling a method in the form that populates it, and this code is "missing" but still working, then simply right-click the method called on the main form, and select 'goto definition' and it will jump to this missing code.

    You can get into trouble if you copy/paste a class (a form is a class) and then rename it. Depending on how you rename it, both classnames may be change, but the filenames are not.

  15. #15
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,117

    Re: Code Missing but form still runs... How can that be possible

    Usually, if I want to figure out what is happening in code I may not be familiar with, instead of hitting F5 (or the "play" button), I just hit the step button, so I'll start stepping through the code from the beginning.
    If you step, and the code goes into run and never returns, then I would say you don't have any code.
    I'm not sure what you mean by the textboxes getting sent data from the main form. I guess that implies these textboxes are on a secondary form.
    Of course you don't have to have any code associated with the textboxes for them to display text, or allow you to type in them. That capability is built into the controls themselves and you won't see that code.

    p.s. I guess I missed that Grimfort has already covered some of what I posted.
    Last edited by passel; Dec 17th, 2014 at 05:28 PM.

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