Windows Phone Developers

Saturday, September 18, 2010

Cint Function in VB.NET / Convert String to Integer in VB.NET

Following snippet provides a hint for Converting an Integer to String

        Dim i1 As Integer

        Integer.TryParse("13", i1)

        MessageBox.Show(i1.ToString())
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Abstract Classes in VB.NET

Abstract classes are base classes that has to be inherited.  A class can be made as an abstract with MustInherit modifier

Abstract classes can contain abstract methods also. Abstract methods are the ones where only signature is available in the base class and their implementation is taken care in derived classes.

Following is an example of abstract class:

Public MustInherit Class ClassAbs



    Public Sub ExampleMethod()

        MessageBox.Show("This is sample")

    End Sub

    Public MustOverride Sub ExampleMethod_ShouldBeInherited()



    Public Overridable Sub ExampleMethod_CanBeCalledFromBase()

        MessageBox.Show("This is sample")

    End Sub

End Class


the class contains one Abstract method

The class can be inherited as shown below:

Public Class ClassDerivedFromAbstract
    Inherits ClassAbs

    Public Sub ExampleAbstract()

        MyBase.ExampleMethod_CanBeCalledFromBase()


    End Sub

    Public Overrides Sub ExampleMethod_ShouldBeInherited()


    End Sub

    Public Overrides Sub ExampleMethod_CanBeCalledFromBase()

        MessageBox.Show("This is sample from Derived")

    End Sub

End Class


The class can be used as shown below:

Dim CAb As New ClassDerivedFromAbstract

        CAb.ExampleMethod_CanBeCalledFromBase()
        CAb.ExampleMethod_ShouldBeInherited()


the first call uses the method from the base class and the second one uses the Method we had overriden in the derived class Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Thursday, September 16, 2010

How to make Windows Form fit FullScreen using VB.NET

We have already seen How to Get Width and Height of Desktop Screen using C#/VB.NET in previous post. The following VB.NET snippet provides a method to make the Windows Form fir the Desktop screen

Dim iWidth As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim iHeight As Integer = Screen.PrimaryScreen.Bounds.Height

        Me.Width = iWidth
        Me.Height = iHeight

        Me.Location = New System.Drawing.Point(0, 0)



You can add this snippet in Form_Load sub Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon