Skip to main content

Small Function VB.Net & C#

VB             C#

UBound()     = yourArray.GetUpperBound(0) or yourArray.Length for one-dimesional arrays
LBound()     = yourArray.GetLowerBound(0)
IsNothing()  = Object.ReferenceEquals(obj,null)
Chr()        = Convert.ToChar()
Len()        = "string".Length
UCase()      = "string".ToUpper()
LCase()      = "string".ToLower()
Left()       = "string".Substring(0, length)
Right()      = "string".Substring("string".Length - desiredLength)
RTrim()      = "string".TrimEnd()
LTrim()      = "string".TrimStart()
Trim()       = "string".Trim()
Mid()        = "string".Substring(start, length)
Replace()    = "string".Replace()
Split()      = "string".Split()
Join()       = String.Join()
MsgBox()     = MessageBox.Show()
IIF()        = (boolean_condition ? "true" : "false")



  • UBound()arrayVar.Length
  • LBound() — obsolete, lower bound is always 0 in a normal .Net array
  • IsNothing() — obsolete. Use Is Nothing in VB.Net and == null in C#
  • Chr()Convert.ToChar() or (char)someVar
  • Len()stringVar.Length use this in VB too
  • UCase()stringVar.ToUpper() use this in VB too
  • LCase()stringVar.ToLower() use this in VB too
  • Left()stringVar.Substring(0, n) use this in VB too
  • Right()stringVar.Substring(stringVar.Length - n) use this in VB too
  • RTrim()stringVar.TrimEnd() use this in VB too
  • LTrim()stringVar.TrimStart() use this in VB too
  • Trim()stringVar.Trim() use this in VB too
  • Mid()stringVar.Substring(n, m) use this in VB too
  • Replace()stringVar.Replace() use this in VB too
  • Split()stringVar.Split() use this in VB too
  • Join()String.Join() use this in VB too
  • MsgBox()MessageBox.Show()
  • IIF()(condition) ? truepart : falsepart - note that there are some differences, because "?" is an operator and not a function

Comments

Popular posts from this blog

Pop Up message Visual Studio "The operation could not be completed. The process cannot access the file because it is being used by another process"

Run your Visual Studio as Administrator account

Create Comment As .xls In Farpoint Spread

  Private Sub TAGS_PARENTING()         Dim DTPopUp As New DataTable         With DTPopUp             .Columns.Add("SEQ", GetType(String))             .Columns.Add("QTY", GetType(String))             .Columns.Add("ETD", GetType(String))             .Columns.Add("ETA", GetType(String))             DTPopUp = MePostab_Control.Cari_TAG_PARENTING         End With         With FPPOSTAB             For GG As Integer = 0 To .ActiveSheet.RowCount - 1             ...