Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows and Extended desktop

Posted on 2016-08-08
9
Medium Priority
?
74 Views
Last Modified: 2016-08-09
I'm trying to code this in VB.NET desktop app.  But I get syntax errors.  What is wrong?

  <StructLayout(LayoutKind.Sequential)>
    Public Structure IntegerPoint
        Public Property X() As Integer
        Public Property Y As Integer
    End Structure

error
0
Comment
Question by:HLRosenberger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 41747276
Did you mean to make X an integer array, Public Property X() As Integer, or did you mean to make it an integer like this, Public Property X As Integer?
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 41747283
Depends on the syntax error.
Otherwise, just check if this is on top of your code:

Imports System.Runtime.InteropServices
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41747320
as per the definition on http://www.pinvoke.net/default.aspx/Structures/POINT.html, X is not an array (as pointed by Fernando). You need to remove the () after X:
  <StructLayout(LayoutKind.Sequential)>
    Public Structure IntegerPoint
        Public Property X As Integer
        Public Property Y As Integer
    End Structure

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:HLRosenberger
ID: 41747324
Nothing I try works, using that <StructLayout(LayoutKind.Sequential)> syntax.

This below works just fine.  Is there any difference?


    Public Structure IntegerPoint
        Public x As Integer
        Public y As Integer
    End Structure

    Public Structure IntegerRect
        Public Left As Integer
        Public Top As Integer
        Public Width As Integer
        Public Height As Integer
    End Structure

    Public Structure WindowPlacement
        Public Length As Integer
        Public Flags As Integer
        Public ShowCommand As Integer
        Public MinPosition As IntegerPoint
        Public MaxPosition As IntegerPoint
        Public NormalPosition As IntegerRect
    End Structure
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 1000 total points
ID: 41747330
the () after the property name indicates that the property is an array which in this case does not fit the definition of a point
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 41747349
What is the exact error you are getting now? Please post.
0
 
LVL 34

Accepted Solution

by:
it_saige earned 1000 total points
ID: 41747610
You are missing the new line specifier in your original code:
<StructLayout(LayoutKind.Sequential)> _
Public Structure IntegerPoint
	Public Property X() As Integer
	Public Property Y() As Integer
End Structure

Open in new window

Notice that the error indicator starts on the end of your StructLayout line, this indicates that the error starts here:Capture.JPGWith regards to array declaration, for properties, you specify if you want the property to be an array by using the array notation on the Type.

Proof of concept -
Imports System.Runtime.InteropServices

Module Module1
	Sub Main()
		Dim point1 As New IntegerPoint() With {.X = 1, .Y = 2, .XArr = New Integer() {1, 2, 3, 4, 5}, .YArr = New Integer() {1, 2, 3, 4, 5}}
		Console.WriteLine("X = {0}, Y = {1}, X-Array = {{{2}}}, Y-Array = {{{3}}}", point1.X, point1.Y, String.Join(";", point1.XArr), String.Join(";", point1.YArr))
		Console.ReadLine()
	End Sub
End Module

<StructLayout(LayoutKind.Sequential)> _
Public Structure IntegerPoint
	'' Not an array
	Public Property X() As Integer
	'' Not an array
	Public Property Y As Integer
	'' ARRAY HERE
	Public Property XArr() As Integer()
	'' ARRAY HERE
	Public Property YArr As Integer()
End Structure

Open in new window

Which produces the following output -Capture.JPGTrying to use the X property as an array results in -Capture.JPG-saige-
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41749196
Thanks for the help.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41749197
thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question