Marking A Class Static in VB.NET

Module == static class If you just want a class that you can’t inherit, use a NotInheritable class; but it won’t be static/Shared. You could mark all the methods, properties, and members as Shared, but that’s not strictly the same thing as a static class in C# since it’s not enforced by the compiler. If … Read more

VB.NET equivalent of C# property shorthand?

There is no shorthand for Visual Studio 2008 or prior for VB.NET. In Visual Studio 2010 and beyond, you can use the following shorthand: Public Property FirstName as String This will be handled as your short version in C# is – I think they call it “Auto Property” See also: Auto-Implemented Properties (Visual Basic)

Listen to key press when the program is in the background

You can use P/Invocation to be able to use WinAPI’s GetAsyncKeyState() function, then check that in a timer. <DllImport(“user32.dll”)> _ Public Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short End Function Const KeyDownBit As Integer = &H8000 Private Sub Timer1_Tick(sender As Object, e As System.EventArgs) Handles Timer1.Tick If (GetAsyncKeyState(Keys.LWin) And KeyDownBit) = KeyDownBit AndAlso (GetAsyncKeyState(Keys.O) … Read more

How to convert date format in vb.net?

Assuming you want to convert the xml string value to a proper DateTime variable, Net has many methods for this: ‘ a date value in the string format specified: Dim xmlDate As String = “07/15/2014 7:07:33 AM” ‘ create a DATE variable from that string in a known format: Dim newDate As Date = DateTime.ParseExact(xmlDate, … Read more

Exposing Property as Variant in .NET for Interop

COM Automation supports a default property, the property that has dispid 0. This is used in VB6 code to great effect, generating really compact code. A typical example is: rs!Customer = “foo” Which is syntax sugar for: rs.Fields.Item(“Customer”).Value = “foo” Three default properties being used here without being named in the original statement. The Recordset … Read more

techhipbettruvabetnorabahisbahis forumu