Top 10 reads of July 2015

These are our Top 10 reads of July 2015.

  • How to match strings using wildcards in C# and VB.NET
  • IsSmallerThan generic extension method for C# and VB.NET
  • How to prevent your IOS app from going into sleeping mode using Objective-C
  • How to convert Color to Hex and Hex to Color using C# and VB.NET
  • How to read a embedded resource to String in C# and VB.NET
  • How to convert a Securestring to String using C# and VB.NET
  • How to change the encoding of a String using C# and VB.NET
  • How to get focusedrow cell value using Devexpress XtraGrid in C# and VB.NET
  • How to get the selected row index in Devexpress Xtragrid Control using C# and VB.NET
  • thanks to all visitors, bookmark us, share us, talk about us, Follow us!, Like us! let’s grow bigger! You can even participate in our Github Projects!

    How to show and select a file in explorer using VBA

    To show and select a file in explorer using VBA you can use the following snippet.
    This snippet should also work in VB6.

    Sample VBA

    Dim path As String
    Dim explorerPath As String
    Dim cmd As String
    
    explorerPath = Environ$("WINDIR") + "\Explorer.exe "
    path = "C:\Users\Codesnippets\Desktop\test\Test.xml"
    cmd = explorerPath + " /select , " + Chr(34) + path + Chr(34)
    Call Shell(cmd, vbNormalFocus)
    

    How to create and write a textfile in VBA

    To create and write a textfile in VBA you can use the following snippet.
    This should also work when using VB6.

    Sample VBA

    Dim fso as Object
    Dim oFile as Object
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oFile = FSO.CreateTextFile("C:\Users\Codesnippets\Desktop\Test.txt")
    
    oFile.WriteLine "This is a sample line!" 
    oFile.Close
    
    Set fso = Nothing
    Set oFile = Nothing  
    

    Mid, Left, Right Extension Methods for C# and VB.NET

    Here are three Extension Methods which let you use the Left, Mid and Right Methods from VB6 in C# and VB.NET. The Extension Methods simply wrap the on-board .NET Framework Method Substring. These Extension Methods are now part of the Fesslersoft.Extensions.

    Samples

    C# Sample

    VB.NET Sample

    Compatibility (as Extension method):
    working .NET 2.0 working .NET 3.0 not tested .NET 3.5 not working .NET 4.0 not working .NET 4.5
    Compatibility (Non-Extension method):
    working .NET 2.0 working .NET 3.0 not tested .NET 3.5 not working .NET 4.0 not working .NET 4.5

    If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

    Related links: