How to write "x = unchecked((int)0x80000000);" with C# on Visual Basic 2008?

C

cameri2005

Hello. In project Visual Studio 2008, Visual C#, Windows Forms Application,
I have written down such code on C# without errors:

        [Flags]

        public enum WindowStyles : uint

        {

            Overlapped = 0x00000000,

            Popup = 0x80000000,

            Child = 0x40000000,

            Minimize = 0x20000000,

            Visible = 0x10000000,

            Disabled = 0x08000000,

            ClipSiblings = 0x04000000,

            ClipChildren = 0x02000000,

            Maximize = 0x01000000,

            Caption = 0x00C00000,

            Border = 0x00800000,

            DialogFrame = 0x00400000,

            VerticalScroll = 0x00200000,

            HorizontalScroll = 0x00100000,

            SystemMenu = 0x00080000,

            ThickFrame = 0x00040000,

            Group = 0x00020000,

            TabStop = 0x00010000,

            MinimizeBox = 0x00020000,

            MaximizeBox = 0x00010000,

        }

x = unchecked((int)0x80000000);

y = 0xffff;

z = 0x0040;

The same code, I have copied in the project Visual Studio 2008, Visual
Basic, Windows Forms Application  in such kind on Visual Basic:

        <Flags()> _

        Public Enum WindowStyles As UInteger

            Overlapped

            Popup

            Child

            Minimize

            Visible

            Disabled

            ClipSiblings

            ClipChildren

            Maximize

            Caption

            Border

            DialogFrame

            VerticalScroll

            HorizontalScroll

            SystemMenu

            ThickFrame

            Group

            TabStop

            MinimizeBox

            MaximizeBox

        End Enum

x = 0

y = 0

z = 0

Building the program occurs without errors, however the result of
performance of the program turns out erroneous.

Inform, please, how correctly to write down this code on Visual Basic?

Many thanks, Zharkov, Moskva, Rossiya.

That's because you still have to give values to each constant inside
the enumerator: example:
Code:
<Flags()> Enum MyFlags
None = 0
First = &H1
Second = &H2
Third = &H4
Fourth = Third << 1 'also a possible way of defining a constant in
terms of the other one, Forth is equal to &H8 right now.
End Enum
 
H

Herfried K. Wagner [MVP]

Dr. Zharkov said:
Hello. In project Visual Studio 2008, Visual C#, Windows Forms
Application,
I have written down such code on C# without errors:

[Flags]

public enum WindowStyles : uint

{

Overlapped = 0x00000000,

Popup = 0x80000000,

Child = 0x40000000,

Minimize = 0x20000000,

Visible = 0x10000000,

Disabled = 0x08000000,

ClipSiblings = 0x04000000,

ClipChildren = 0x02000000,

Maximize = 0x01000000,

Caption = 0x00C00000,

Border = 0x00800000,

DialogFrame = 0x00400000,

VerticalScroll = 0x00200000,

HorizontalScroll = 0x00100000,

SystemMenu = 0x00080000,

ThickFrame = 0x00040000,

Group = 0x00020000,

TabStop = 0x00010000,

MinimizeBox = 0x00020000,

MaximizeBox = 0x00010000,

}



x = unchecked((int)0x80000000);

y = 0xffff;

z = 0x0040;
[...]
Inform, please, how correctly to write down this code on Visual Basic?

\\\
<Flags()> _
Public Enum WindowStyles As UInteger
Overlapped = &H0
Popup = &H80000000UL
Child = &H40000000
Minimize = &H20000000
Visible = &H10000000
Disabled = &H8000000
ClipSiblings = &H4000000
ClipChildren = &H2000000
Maximize = &H1000000
Caption = &HC00000
Border = &H800000
DialogFrame = &H400000
VerticalScroll = &H200000
HorizontalScroll = &H100000
SystemMenu = &H80000
ThickFrame = &H40000
Group = &H20000
TabStop = &H10000
MinimizeBox = &H20000
MaximizeBox = &H10000
End Enum

Public Sub Test()
Dim x As UInteger = &H80000000UL
MsgBox(Hex(x))
End Sub
///
 
S

Steve Gerrard

Dr. Zharkov said:
Mr. Herfried K. Wagner.

Many thanks for the answer.

Following your code, I have correctly written down last three lines
of a code?

x = unchecked((int)0x80000000); --> Dim x As Integer = &H80000000

z = 0x0040; --> z = &H40



And how to write on Visual Basic last line?

y = 0xffff; --> ?

Many thanks, Zharkov.

Replace 0x with &H.
 
H

Herfried K. Wagner [MVP]

Dr. Zharkov said:
Following your code, I have correctly written down last three lines of a
code?

x = unchecked((int)0x80000000); --> Dim x As Integer = &H80000000

z = 0x0040; --> z = &H40

And how to write on Visual Basic last line?

y = 0xffff; --> ?

The translation depends on the data type of the variables 'x', 'y', and 'z'
respectively. '0x0040' translates to '&H40' and '0xffff' translates to
'&HFFFF', however, you may have to append the proper type suffices in order
to get it work.
 
D

Dr. Zharkov

Hello. In project Visual Studio 2008, Visual C#, Windows Forms Application,
I have written down such code on C# without errors:

[Flags]

public enum WindowStyles : uint

{

Overlapped = 0x00000000,

Popup = 0x80000000,

Child = 0x40000000,

Minimize = 0x20000000,

Visible = 0x10000000,

Disabled = 0x08000000,

ClipSiblings = 0x04000000,

ClipChildren = 0x02000000,

Maximize = 0x01000000,

Caption = 0x00C00000,

Border = 0x00800000,

DialogFrame = 0x00400000,

VerticalScroll = 0x00200000,

HorizontalScroll = 0x00100000,

SystemMenu = 0x00080000,

ThickFrame = 0x00040000,

Group = 0x00020000,

TabStop = 0x00010000,

MinimizeBox = 0x00020000,

MaximizeBox = 0x00010000,

}



x = unchecked((int)0x80000000);

y = 0xffff;

z = 0x0040;



The same code, I have copied in the project Visual Studio 2008, Visual
Basic, Windows Forms Application in such kind on Visual Basic:



<Flags()> _

Public Enum WindowStyles As UInteger

Overlapped

Popup

Child

Minimize

Visible

Disabled

ClipSiblings

ClipChildren

Maximize

Caption

Border

DialogFrame

VerticalScroll

HorizontalScroll

SystemMenu

ThickFrame

Group

TabStop

MinimizeBox

MaximizeBox

End Enum



x = 0

y = 0

z = 0



Building the program occurs without errors, however the result of
performance of the program turns out erroneous.

Inform, please, how correctly to write down this code on Visual Basic?

Many thanks, Zharkov, Moskva, Rossiya.
 
D

Dr. Zharkov

Mr. Herfried K. Wagner.

Many thanks for the answer.

Following your code, I have correctly written down last three lines of a
code?

x = unchecked((int)0x80000000); --> Dim x As Integer = &H80000000

z = 0x0040; --> z = &H40



And how to write on Visual Basic last line?

y = 0xffff; --> ?

Many thanks, Zharkov.
 
D

Dr. Zharkov

Many thanks for the answers.

In project Visual Studio 2008, Visual C#, Windows Forms Application, I have
written down such code on C# without errors (with use resulted above Enum):

[Flags]

public enum WindowStyles : uint

{

Overlapped = 0x00000000,

Popup = 0x80000000,

Child = 0x40000000,

Minimize = 0x20000000,

Visible = 0x10000000,

Disabled = 0x08000000,

ClipSiblings = 0x04000000,

ClipChildren = 0x02000000,

Maximize = 0x01000000,

Caption = 0x00C00000,

Border = 0x00800000,

DialogFrame = 0x00400000,

VerticalScroll = 0x00200000,

HorizontalScroll = 0x00100000,

SystemMenu = 0x00080000,

ThickFrame = 0x00040000,

Group = 0x00020000,

TabStop = 0x00010000,

MinimizeBox = 0x00020000,

MaximizeBox = 0x00010000,

}

WindowStyles style = WindowStyles.Overlapped |

WindowStyles.Caption |

WindowStyles.SystemMenu |

WindowStyles.ThickFrame |

WindowStyles.MinimizeBox |

WindowStyles.MaximizeBox;

string WindowClassName = "MD3DWindowClass";

string windowTitle = "Game2";

int windowSize_Width = 648;

int windowSize_Height = 525;

int x = 0;

int y = 0;

private void Form1_Load(object sender, EventArgs e)

{

MessageBox.Show(

"1-Ê ÐÁÒÁÍÅÔÒ = " + Convert.ToString(0) +

", WindowClassName = " +

Convert.ToString(WindowClassName) +

", windowTitle = " +

Convert.ToString(windowTitle) +

", style = " + Convert.ToString(style) +

", x = " + Convert.ToString(x) +

", y = " + Convert.ToString(y) +

", windowSize.Width = " +

Convert.ToString(windowSize_Width) +

", windowSize.Height = " +

Convert.ToString(windowSize_Height) +

", IntPtr.Zero = " +

Convert.ToString(IntPtr.Zero) +

", IntPtr.Zero = " +

Convert.ToString(IntPtr.Zero) +

", IntPtr.Zero = " +

Convert.ToString(IntPtr.Zero) +

", IntPtr.Zero = " +

Convert.ToString(IntPtr.Zero));

}

Panel MessageBox.Show shows the following correct information for variable
"style":

style = TabStop, Group, ThickFrame, SystemMenu, Caption



The same code, I have copied in the project Visual Studio 2008, Visual
Basic, Windows Forms Application in such kind on Visual Basic (with use
resulted above your code):

<Flags()> _

Public Enum WindowStyles As UInteger

Overlapped = &H0

Popup = &H80000000UL

Child = &H40000000

Minimize = &H20000000

Visible = &H10000000

Disabled = &H8000000

ClipSiblings = &H4000000

ClipChildren = &H2000000

Maximize = &H1000000

Caption = &HC00000

Border = &H800000

DialogFrame = &H400000

VerticalScroll = &H200000

HorizontalScroll = &H100000

SystemMenu = &H80000

ThickFrame = &H40000

Group = &H20000

TabStop = &H10000

MinimizeBox = &H20000

MaximizeBox = &H10000

End Enum


Dim style As WindowStyles = _

WindowStyles.Overlapped Or _

WindowStyles.Caption Or _

WindowStyles.SystemMenu Or _

WindowStyles.ThickFrame Or _

WindowStyles.MinimizeBox Or _

WindowStyles.MaximizeBox



Dim WindowClassName As String = "MD3DWindowClass"

Dim windowTitle As String = "Game2"

Dim windowSize_Width As Integer = 648

Dim windowSize_Height As Integer = 525

Dim x As Integer = 0

Dim y As Integer = 0



Private Sub Form1_Load(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles MyBase.Load

MsgBox("1-Ê ÐÁÒÁÍÅÔÒ = " & CStr(0) _

& ", WindowClassName = " _

& CStr(WindowClassName) _

& ", windowTitle = " & CStr(windowTitle) _

& ", style = " & CStr(style) _

& ", x = " & CStr(x) & ", y = " & CStr(y) _

& ", windowSize.Width = " _

& CStr(windowSize_Width) _

& ", windowSize.Height = " _

& CStr(windowSize_Height) _

& ", IntPtr.Zero = " & CStr(IntPtr.Zero) _

& ", IntPtr.Zero = " & CStr(IntPtr.Zero) _

& ", IntPtr.Zero = " & CStr(IntPtr.Zero) _

& ", IntPtr.Zero = " & CStr(IntPtr.Zero))

End Sub



Panel MsgBox shows the following erroneous information for variable "style":

style = 13565952

Inform, please, how correctly to write down this code on Visual Basic?

Many thanks, Zharkov.
 
S

Steve Gerrard

Dr. Zharkov said:
Mr. Herfried K. Wagner.

I live in Moscow (Russia), and on my computer the Moscow time is
established. About what problem you write?

Thanks, Zharkov.

Most posts get adjusted to the local time zone of the person viewing them. Your
posts do not. It is not a big problem, it just means that somewhere between here
and there the time zone information is getting lost.

Since you wrote your post at about 6 am Tuesday morning, Moscow time, it looks
odd to see it listed that way on the west coast of the USA, where it is only
8:30 pm Monday.
 
D

Dr. Zharkov

Mr. Herfried K. Wagner.

I live in Moscow (Russia), and on my computer the Moscow time is
established. About what problem you write?

Thanks, Zharkov.
 
D

Dr. Zharkov

Mr. Steve Gerrard.

Thanks for an explanation. Look, please, the program in my last post from 2
March. You see in the program of errors?

Thanks, Zharkov.
 
Top