Posts Tagged ‘vb.net description’

This service is marked for deletion

This error occurs when you uninstall a windows service.
What you need to do is to close the mmc or services.msc if this was opened.

More information of this error refer to KB Article

, ,

No Comments


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, ” “)

,

No Comments


How to assign Null Values to Date Type Variable in .Net

Actually, you can’t assign a null value to a Date Type variable but you can check if the variable has been set or not by comparing its current value versus default value (#12:00:00 AM#) of date/datetime, you can get the default value by using

  1. Date.MinValue or DateTime.MinValue

To do this, let say you have a variable called LastUpdate with a data type of Datetime

  1. Dim LastUpdate  as DateTime
  2. dim dr as Datarow
  3.  
  4. If DateTime.MinValue = LastUpdate   Then
  5.         'Its Null value
  6.         'if you want to save the value to the database then use the DBNull.Value
  7.         dr("LastUpdate") = DBNull.Value
  8. Else
  9.         dr("LastUpdate") =LastUpdate  
  10. End If

, ,

No Comments


Multithreading in .Net

A lock is a way to tell the computer that the following group of code should be executed together as a single operation, and not let other threads have access to the resource that is locked until the locking code is finished

Source: http://www.developerfusion.com/article/5184/multithreading-in-vbnet/2/

,

No Comments


How to create Temporary filename in vb.Net
  1. Private Sub TempFile()
  2.      Dim sTempFileName AsString = System.IO.Path.GetTempFileName()
  3.      Dim fsTemp AsNew System.IO.FileStream(sTempFileName, IO.FileMode.Create)
  4.  
  5.      MessageBox.Show(sTempFileName)
  6.  
  7.      'write data to the temp file
  8.      fsTemp.Close()
  9.  
  10.      System.IO.File.Delete(sTempFileName)
  11.  End Sub

, , ,

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


Putting Description on Function/Sub Routine

Just Type 3 single quotes (”’)  above the function/ sub routine, VS will automatically generate an XML tags for you. see below

”’ <summary>
”’
”’ </summary>
”’ <param name=”name”></param>
”’ <param name=”index”></param>
”’ <param name=”path”></param>
”’ <remarks></remarks>
Public Sub New(ByVal name As String, ByVal index As Integer, Optional ByVal path As String = “”)
_name = name
_index = index
_path = path
End Sub

,

No Comments



SetPageWidth