Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Location problems. Urgent.

  1. #1

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Resolved [RESOLVED] [2005] Location problems. Urgent.

    Hi,

    Could someone tell me why I'm suddenly getting errors on the following:

    I have a form with a panel which has a WMP control in it. I set its location at run time and then after a 10 second timer event it moves to a new location on the screen and options appear. This work fine.

    I'm essentially trying to do the same thing on a different form involving a panel and a picture box. I'm not getting the 'Point' property from intellisense. I keep getting errors saying it's not an interface type or something. I've tried with and without the New keyword just in case.

    I only get PointConverter or PointF to choose from when i try to set that panel location. Why??

    I can't even do things like: Panel1.Location.X = 23

    Says expression is a value and therefore cannot be the target of the assignment.

    I created a new form, put a panel and picbox and it works. What have I done to make this happen??
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  2. #2

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: [2005] Location problems. Urgent.

    I found out what the problem is.

    I have an Import Excel statement on the form. The problem only happens when that's there. But the location thing doesn't apply to Excel but every time i put that statement in it says: 'New' Cannot be used on an Interface

    Does anyone know how to get around this problem? I see no reason why a panel's location should be causing a problem with Excel
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Location problems. Urgent.

    First of all, you absolutely can NOT do this:
    VB Code:
    1. Panel1.Location.X = 23
    for the very reaosn that the error message says. The Location property returns a value, i.e. a copy of the value stored in the Panel. If you set the X property of that copy then the original is completely unaffected, so even trying is pointless. The compiler will not allow you to set a property of a property directly when the parent property is a value type for that reason. You would have to set the Panel's Left property, which is what its for. Alternatively you can assign the value of the Location property to a variable, set its X property and then assign the variable back to the Location property.

    As for your import issue, I would guess that you are introducing a name clash with your import, i.e. there are two namespaces, types or members with the same name and the IDE is interpreting what you enter as the opposite of what you intend. The norm is to import Office namespaces with an alias:
    VB Code:
    1. Imports Excel = Microsoft.Office.Interop.Excel
    That means that anywhere you want to refer to the Microsoft.Office.Interop.Excel namespace you type Excel. It means that you don't type as much as you would without the import but there'll be no name clashes as all types within that namespace must be qualified.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: [RESOLVED] [2005] Location problems. Urgent.

    Quote Originally Posted by stimbo
    I created a new form, put a panel and picbox and it works. What have I done to make this happen??
    And this is really working?
    VB 2005, Win Xp Pro sp2

  5. #5

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: [RESOLVED] [2005] Location problems. Urgent.

    No, the "it works" reference was in regards to the "New Point(x,y)" working on the other form (without Excel reference). That way worked fine with the panel and pic box. Just bad phrasing on my part. I was just trying everything at the end of it because I was so fed up.

    I've lost the plot. I don't know why I thought Location.X would work. It obviously wouldn't. The Excel thing was the culprit.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

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