Archive for the ‘String Manipulation’ Category

How to Convert Arraylist to String using .Net
  1. Public Overloads Function ArrayListToString(ByVal ar As System.Collections.ArrayList) As String
  2.  Return ArrayListToString(ar, ","C)
  3. End Function
  4.  
  5. Public Overloads Function ArrayListToString(ByVal ar As System.Collections.ArrayList, ByVal delim As Char) As String
  6.  Return ArrayListToString(ar, delim.ToString)
  7. End Function
  8.  
  9. Public Overloads Function ArrayListToString(ByVal ar As System.Collections.ArrayList, ByVal delim As String) As String
  10.  Return String.Join(delim, CType(ar.ToArray(GetType(String)), String()))
  11. End Function

, , ,

No Comments


How to convert string to Hex
  1. Function HexToDec(ByVal value As String) As Long
  2.     ' we just need a call to the Convert.ToInt64 static method
  3.     Return Convert.ToInt64(value, 16)
  4. End Function

,

No Comments


How to Convert String to Date Format

To Convert String To Date Format, use the DateTime.ParseExact function

DateTime.ParseExact(s as String, format as String, provider As IFormatProvider) as DateTime

Parameters:

s
Type: System.String
A string that contains a date and time to convert. 
format
Type: System.String
A format specifier that defines the required format of s
provider
Type: System.IFormatProvider
An object that supplies culture-specific format information about s

Example:
 

  1.     Private Function ToDate() As DateTime
  2.  
  3.         Dim str As String = "20060505"
  4.  
  5.         Dim mDate As DateTime
  6.  
  7.  
  8.  
  9.         mDate = DateTime.ParseExact(str, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat)
  10.  
  11.         Return mDate
  12.  
  13.     End Function

Read More about DateTime.ParseExact Method (String, String, IFormatProvider)

,

No Comments


How to Clear StringBuilder

How to clear StringBuilder data;

Dim StrB as new StringBuilder

1. Way to clear is to set the Length to 0

  1.  StrB.Lenght = 0

2. Or reassign it

  1.  
  2. StrB = new StringBuilder   

, ,

No Comments



SetPageWidth