Solved

Windows and Extended desktop

Posted on 2016-08-08
9
68 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 63

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
Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

 
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 250 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 63

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

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

624 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