It looks like a function but it is an operator. The Visual Basic If operator provides the functionality of the IIF function and more - including short-circuiting. It can be use as a ternary operator which mimics the functionality of the IIF function while adding some more to it, and as a binary operator which provides a comparison/assignment feature.
The operator uses short-circuit evaluation to conditionally return one of two values. The If operator can be called with three arguments or with two arguments.
When If is called by using three arguments, the first argument must evaluate to a value that can be cast as a Boolean. That Boolean value will determine which of the other two arguments is evaluated and returned.
' This statement prints TruePart, because the first argument is true. Console.WriteLine(If(True, "TruePart", "FalsePart")) ' This statement prints FalsePart, because the first argument is false. Console.WriteLine(If(False, "TruePart", "FalsePart")) Dim number = 3 ' With number set to 3, this statement prints Positive. Console.WriteLine(If(number >= 0, "Positive", "Negative")) number = -1 ' With number set to -1, this statement prints Negative. Console.WriteLine(If(number >= 0, "Positive", "Negative"))
The Bing Code Snippets package uses the Code Snippets technology of Visual Studio to provide blocks of code that you can insert into your C# or JavaScript Windows Store applications.
These snippets support the following Bing technologies:
Download them here.
Windows 8.1 includes the new Back button control. The BackButton provides a way for you to add backward navigation to your app.
<button data-win-control="WinJS.UI.BackButton" >button>
You don't have to write any code. The BackButton automatically checks the navigation stack to determine whether the user can navigate backwards. If there is nothing to navigate back to, the button disables itself. When the user clicks the button or uses keyboard shortcuts (such as Alt+Left or the BrowserBack keys), it automatically calls the WinJS.Navigation.back function to navigate backwards.
Developed in collaboration with AppendTo and Sauce Labs, BrowserSwarm is powered through the cloud, allowing developers to save time setting up multiple browser or device testing environments and precious server resources, Microsoft said.
Read More
My Code Brain page hosts a cloud full of code for C#, Visual Basic, JavaScript, HTML, CSS and more.
Incorporating digital ink into Visual Basic WPF applications is done with the Microsoft.Ink DLL. Ink has evolved COM and Windows Forms to full integration into the WPF. You do not need to install separate SDKs or runtime libraries.
Below is an example of using procedural code with Ink. Ink can also be used with XAML.
Imports Microsoft.Ink Public Class Form1 Dim WithEvents myInkOverlay As InkOverlay Dim selectedMode As InkOverlayEditingMode Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() myInkOverlay = New InkOverlay(Panel1) myInkOverlay.Enabled = True End Sub 'Back of pen erase Sub CursorInRangeEventHandler(ByVal sender As Object, ByVal e As InkCollectorCursorInRangeEventArgs) Handles myInkOverlay.CursorInRange 'If the pen is inverted, set mode to "delete" If (e.Cursor.Inverted) Then myInkOverlay.EditingMode = InkOverlayEditingMode.Delete Else 'Pen is not inverted, so select whatever mode the user requested myInkOverlay.EditingMode = selectedMode End If End Sub 'Ink mode radio button Sub InkRadioClickedHandler(ByVal sender As Object, ByVal e As EventArgs) Handles RadioButton1.CheckedChanged If (RadioButton1.Checked) Then selectedMode = InkOverlayEditingMode.Ink DoModeChange(InkOverlayEditingMode.Ink) End If End Sub 'Select mode radio button Sub SelectRadioClickedHandler(ByVal sender As Object, ByVal e As EventArgs) Handles RadioButton2.CheckedChanged If (RadioButton2.Checked) Then selectedMode = InkOverlayEditingMode.Select DoModeChange(InkOverlayEditingMode.Select) End If End Sub 'Delete mode radio button Sub DeleteRadioClickedHandler(ByVal sender As Object, ByVal e As EventArgs) Handles RadioButton3.CheckedChanged If (RadioButton3.Checked) Then selectedMode = InkOverlayEditingMode.Delete DoModeChange(InkOverlayEditingMode.Delete) End If End Sub 'Wire up delete mode buttons 'Delete entire stroke Sub StrokeRadioClickedHandler(ByVal sender As Object, ByVal e As EventArgs) Handles RadioButton4.CheckedChanged 'Can be called during Form construction, prior to myInkOverlay instantiation If (myInkOverlay Is Nothing) Then Return End If If (RadioButton4.Checked) Then myInkOverlay.EraserMode = InkOverlayEraserMode.StrokeErase End If End Sub 'Delete point(s) at pen tip only Sub PointRadioClickedHandler(ByVal sender As Object, ByVal e As EventArgs) Handles RadioButton5.CheckedChanged If (RadioButton5.Checked) Then myInkOverlay.EraserMode = InkOverlayEraserMode.PointErase End If End Sub Sub DoModeChange(ByVal NewMode As InkOverlayEditingMode) 'Can be called during Form construction, prior to myInkOverlay instantiation If (myInkOverlay Is Nothing) Then Return End If 'Switch the collection mode myInkOverlay.EditingMode = NewMode 'Switch the radio buttons to reflect new mode Select Case NewMode Case InkOverlayEditingMode.Ink RadioButton1.Checked = True RadioButton2.Checked = False RadioButton3.Checked = False Case InkOverlayEditingMode.Select RadioButton1.Checked = False RadioButton2.Checked = True RadioButton3.Checked = False Case InkOverlayEditingMode.Delete RadioButton1.Checked = False RadioButton2.Checked = False RadioButton3.Checked = True Case Else Throw New ArgumentOutOfRangeException() End Select End Sub End Class
The recommended way to create a Windows Communication Foundation (WCF) contract is with an interface. Acontract specifies the collection and structure of messages required to access the operations the service offers.
The ServiceContractAttribute class is used to indicate that an interface or a class defines a service contract in a Windows Communication Foundation (WCF) application.
A class can support multiple contracts by deriving and implementing multiple interfaces decorated with the ServiceContract attribute.
<ServiceContract> _ Interface IMyContract <OperationContract> _ Function MyMethod() As String End Interface <ServiceContract> _ Interface IMyOtherContract <OperationContract> _ Sub MyOtherMethod() End Interface Class MyService Implements IMyContract Implements IMyOtherContract Public Function MyMethod() As String Implements IMyContract.MyMethod End Function Public Sub MyOtherMethod() Implements IMyOtherContract.MyOtherMethod End Sub End Class
From Wikipedia: “Parallax is a displacement or difference in the apparent position of an object viewed along two different lines of sight, and is measured by the angle or semi-angle of inclination between those two lines.”
A Parallax can create an interesting visual effect when used for a background in a Windows Store App.
David Catuhe explain how in this blog post ‘How to create a cool parallax background’.
public static class ExtNumbers
{
public static decimal ToDecimal(this string value)
decimal result = Con.D0000m;
if (String.IsNullOrEmpty(value))
return result;
}
decimal.TryParse(value, out result);