Convert String to Double – VB
Try looking at Double.TryParse() if you are using .NET 1.1/2.0/3.0/3.5/4.0/4.5
Try looking at Double.TryParse() if you are using .NET 1.1/2.0/3.0/3.5/4.0/4.5
This is the first post on google so I thought I’d post different ways that are available and how they compare. Unfortunately I can’t figure out how to create a table here, so it’s an image. The code for each is below the image using fully qualified names. My.Application.Info.DirectoryPath Environment.CurrentDirectory System.Windows.Forms.Application.StartupPath AppDomain.CurrentDomain.BaseDirectory System.Reflection.Assembly.GetExecutingAssembly.Location System.Reflection.Assembly.GetExecutingAssembly.CodeBase New … Read more
Value vis-a-vis Reference Types Variables in C# are in 1 of 2 groups. Value types or Reference types. Types like int and DateTime are value types. In contrast, any class you create is a reference type. C# strings are also a reference type. Most things in the .NET framework are reference types. Parts of a … Read more
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
You need to convert the code to an expression tree. using System; using System.Linq; using System.Linq.Expressions; using System.Reflection; namespace WindowsFormsApplication1 { static class Program { [STAThread] static void Main() { using (var context = new NorthwindEntities()) { IQueryable<Customer> query = context.Customers; query = Simplified<Customer>(query, “CustomerID”, “ALFKI”); var list = query.ToList(); } } static IQueryable<T> Simplified<T>(IQueryable<T> … Read more
Function getHTTPStream() As String Dim myh As HttpWebRequest = _ HttpWebRequest.Create(“http://yourmagentoweb/soap/api/?wsdl”) myh.Timeout = 30000 myh.UserAgent = “Test” Dim myR As HttpWebResponse = myh.GetResponse() Dim myEnc As Encoding = Encoding.GetEncoding(1252) Dim mySr As StreamReader = New StreamReader(myR.GetResponseStream(), myEnc) Return mySr.ReadToEnd() End Function That code needs tweaking obviously- i have not got time to prettify this stuff … Read more
There is one that comes with vb.net. When you open a .vbp vb6 project, it asks if you would like to automatically convert it to vb.net. It does a pretty good job, exclusive of third party add-ons.
There’s no equivalent of C#’s volatile keyword in VB.NET. Instead what’s often recommended is the use of MemoryBarrier. Helper methods could also be written: Function VolatileRead(Of T)(ByRef Address As T) As T VolatileRead = Address Threading.Thread.MemoryBarrier() End Function Sub VolatileWrite(Of T)(ByRef Address As T, ByVal Value As T) Threading.Thread.MemoryBarrier() Address = Value End Sub Also … Read more
This may be an issue with DPI awareness. Specifically, your application is not declared as being DPI aware and when your code accesses the Microsoft.ACE.OLEDB provider, its process is set to being DPI aware. This is something that I discovered by accident a while ago, but I never seen anyone else report it happening. The … Read more
This is done easiest by implementing the IMessageFilter interface in your main form. It lets you sniff at input messages before they are dispatched. Restart a timer when you see the user operating the mouse or keyboard. Drop a timer on the main form and set the Interval property to the timeout. Start with 2000 … Read more