Archive for the ‘VB.Net’ Category
How to convert .net Form to Image
-
Public Class Form1
-
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-
CreateBitmap(Me)
-
End Sub
-
-
Private Sub CreateBitmap(ByVal con As Control)
-
'Dim g As Graphics = Me.CreateGraphics()
-
-
Dim b As Bitmap = New Bitmap(Me.Width, Me.Height)
-
Me.DrawToBitmap(b, New Rectangle(0, 0, Me.Width, Me.Height))
-
-
b.Save("test.jpg", Imaging.ImageFormat.Jpeg)
-
b.Dispose()
-
'g.Dispose()
-
End Sub
-
End Class
Enum: How to get the underlying value given the name
Use Parse method of the enum to get the value:
Enum x
a = 1
b = 2
End Enum
dim e as x
e = [enum].Parse(GetType(x), “a”)
The following text is not allowed in this context:
This exception occurs when there is an extra string / character outside the element of the schema,
example:

How to Convert Arraylist to String using .Net
Posted by: admin in Array, String Manipulation, VB.Net on October 28th, 2009
-
Public Overloads Function ArrayListToString(ByVal ar As System.Collections.ArrayList) As String
-
Return ArrayListToString(ar, ","C)
-
End Function
-
-
Public Overloads Function ArrayListToString(ByVal ar As System.Collections.ArrayList, ByVal delim As Char) As String
-
Return ArrayListToString(ar, delim.ToString)
-
End Function
-
-
Public Overloads Function ArrayListToString(ByVal ar As System.Collections.ArrayList, ByVal delim As String) As String
-
Return String.Join(delim, CType(ar.ToArray(GetType(String)), String()))
-
End Function
How to convert string to Hex
Posted by: admin in .NET, String Manipulation, VB.Net on September 8th, 2009
-
Function HexToDec(ByVal value As String) As Long
-
' we just need a call to the Convert.ToInt64 static method
-
Return Convert.ToInt64(value, 16)
-
End Function
How to Replace Multiple space with only one space
Use regular expression
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(@”[ ]{2,}”, options);
tempo = regex.Replace(tempo, @” “);
VB.Net
Dim str As String = “Sample space 01″
Dim opts As RegexOptions = RegexOptions.None
Dim regx As New Regex(”[ ]{2,}”, opts)
str = regx.Replace(str, ” “)
Subtracting Days of the Date
Posted by: admin in .NET, C#, Date Formatting, VB.Net on May 26th, 2009
To subtract the date with a specified number of days, use the built in shared function of the Date which Date.Today.Add(Days), where Days is a day number. Instead of passing a positive number of days, put a negative sign in it.
Example to subtract 2 days from the current date.
Date.Today.Add(-2)
or you can also use the DateAdd() function and pass a negative day number.