Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Tuesday, November 1, 2011

Excel VBA: String Format

The functions string.Format or StringBuilder.AppendFormat are two very usefull functions for formatting strings and increasing the readability of your .NET code. The Format function in VBA unfortunately works in a quite different way than the string.Format function in .NET. As far as I know there is no built-in function in VBA to acomplish the exact same as string.Format. In VBA the functionality can be achieved the following way:

' Format string using the .NET way
Public Function StringFormat(ByVal strValue As String, ParamArray arrParames() As Variant) As String
    Dim i As Integer

    ' Replace parameters  
    For i = LBound(arrParames()) To UBound(arrParames())
        strValue = Replace(strValue, "{" & CStr(i) & "}", CStr(arrParames(i)))
    Next
   
    ' Get the value    StringFormat = strValue
End Function



For more information please visit

Saturday, October 8, 2011

Facebook Dev: Choosing a SDK for ASP.NET

When first deciding to create a Facebook App in ASP.NET I was struggling to find a up to date Facebook SDK for .NET. Some of the SDKs contains very low level functions, while others don't support the latest features. When selecting SDK you also have to make sure that the "new" signed_request parameter is used by the framework. From October 1st 2011 all Facebook Apps and Facebook Pages must use this parameter to get information about the current user, page id, access token etc.

At the time of writing, it seems like it is only the offical Facebook SDK at CodePlex which is satisfying all the requirements when it comes to Facebook Development in .NET.
Unfortunately, the SDK contains a lot of bugs, and is very hard to debug if you happens to find one.

Personally I was forced to write most of my Facebook code from scratch without using the Facebook SDK due to all the bugs.

You can find the documentation of the Facebook API at the Developer area.

.NET: SVG Support

After hours of searching for code for rendering SVG pictures I finally stumbled upon the SVG rendering engine at Codeplex.

The good thing about SVG is that it is supported in most modern browsers. However, SVG is not supported in .NET so you need to find an external library. It seems like Microsoft has focused all their energy on XAML, even though the two formats are very similar.

Fortunately for us the SVG Rendering Engine works more or less out of the box. I had to do some rewriting of the code to make it work with all SVG images. The library is still under development and needs a lot of new features to make it work 100% in accordance with the specifications.