July 10, 2009

.Net- Difference between Class and Struct.

1- Classes are references type that required to allocate of heap.
1- Struct are values type that do not required to allocate of heap

2- Classes contains a referance of the data.
2- Struct directly contains the original data.

3- Classes can inherit from other classes and interface.
3- Struct can inherit from interface only.

4- Classes are used to store larger data(more data 16 bytes)
4- Struct are used to store less data(16 bytes or less)

5- To instantiate an object of a class, you use the new keyword.
5- You donot require the new keyword to create a instane of a struct.

July 3, 2009

VB.Net- Enter AlphaNumeric Values

Private Sub txtRemark_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles

txtRemark.KeyPresse.Handled = OnlyAlphaNumeric(e.KeyChar)

End Sub

Public Function OnlyAlphaNumeric(ByVal Value As String) As Boolean
OnlyAlphaNumeric = True
If (Microsoft.VisualBasic.Asc(Value) >= 65 And Microsoft.VisualBasic.Asc(Value) <= 90) _ Or (Microsoft.VisualBasic.Asc(Value) >= 97 And Microsoft.VisualBasic.Asc(Value) <= 122) _ Or (Microsoft.VisualBasic.Asc(Value) >= 48 And Microsoft.VisualBasic.Asc(Value) <= 57) Then

OnlyAlphaNumeric = False

End If

If (Microsoft.VisualBasic.Asc(Value) = 32) Then OnlyAlphaNumeric = False End If

If (Microsoft.VisualBasic.Asc(Value) = 13) Then OnlyAlphaNumeric = False End If

End Function