Results 1 to 9 of 9

Thread: work with string......

Threaded View

  1. #1

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    work with string......

    Hi every one. This write will mention to string which we frequently meet it.
    ( i collected on the internet)


    How to VB.NET String.Length()

    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str As String
            str = "This is a Test"
            MsgBox(str.Length())
        End Sub
    End Class
    How to VB.NET String.Insert()

    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str As String = "This is VB.NET Test"
            Dim insStr As String = "Insert "
            Dim strRes As String = str.Insert(15, insStr)
            MsgBox(strRes)
        End Sub
    End Class
    How to VB.NET String.IndexOf()

    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str As String
            str = "VB.NET TOP 10 BOOKS"
            MsgBox(str.IndexOf("BOOKS"))
        End Sub
    End Class
    How to VB.NET String.Format()

    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim dNum As Double
            dNum = 32.123456789
            MsgBox("Formated String " & String.Format("{0:n4}", dNum))
        End Sub
    End Class
    How to VB.NET String.Equals()

    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str1 As String = "Equals"
            Dim str2 As String = "Equals"
    
            If String.Equals(str1, str2) Then
                MsgBox("Strings are Equal() ")
            Else
                MsgBox("Strings are not Equal() ")
            End If
        End Sub
    End Class
    How to VB.NET String.Copy()

    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str1 As String
            Dim str2 As String
    
            str1 = "VB.NET Copy() test"
            str2 = String.Copy(str1)
    
            MsgBox(str2)
        End Sub
    End Class
    How to VB.NET String.CopyTo()
    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str1 As String = "CopyTo() sample"
            Dim chrs(5) As Char
            str1.CopyTo(0, chrs, 0, 6)
            MsgBox(chrs(0) + chrs(1) + chrs(2) + chrs(3) + chrs(4) + chrs(5))
        End Sub
    End Class
    How to VB.NET String.Contains()
    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str As String
            str = "VB.NET TOP 10 BOOKS"
            If str.Contains("TOP") = True Then
                MsgBox("The string Contains() 'TOP' ")
            Else
                MsgBox("The String does not Contains() 'TOP'")
            End If
        End Sub
    End Class
    How to VB.NET String.Compare()


    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str1 As String
            Dim str2 As String
    
            str1 = "vb.net"
            str2 = "VB.NET"
    
            Dim result As Integer
    
            result = String.Compare(str1, str2)
            MsgBox(result)
    
            result = String.Compare(str1, str2, True)
            MsgBox(result)
        End Sub
    End Class
    How to VB.NET String.Clone()
    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str As String = "Clone() Test"
            Dim clonedString As String
            clonedString = str.Clone()
            MsgBox(clonedString)
        End Sub
    End Class
    How to VB.NET String.Chars()

    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            Dim str As String = "Returned Character Chars()"
            Dim singleChar As Char
            singleChar = str.Chars(3)
            MsgBox(singleChar)
        End Sub
    End Class
    How to VB.NET String.substring()
    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim str As String
            Dim retString As String
            str = "This is substring test"
            retString = str.Substring(8, 9)
            MsgBox(retString)
    
        End Sub
    End Class
    How to VB.NET String.Split()
    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim str As String
            Dim strArr() As String
            Dim count As Integer
            str = "vb.net split test"
            strArr = str.Split(" ")
            For count = 0 To strArr.Length - 1
                MsgBox(strArr(count))
            Next
    
        End Sub
    End Class
    How to VB.NET String.EndsWith()
    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, 
    		ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim str As String
            str = "VB.NET TOP 10 BOOKS"
            If str.EndsWith("BOOKS") = True Then
                MsgBox("The String EndsWith 'BOOKS' ")
            Else
                MsgBox("The String does not EndsWith 'BOOKS'")
            End If
    
        End Sub
    End Class


    How to VB.NET String.Concat()

    Code:
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, _
    	ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim str1 As String
            Dim str2 As String
    
            str1 = "Concat() "
            str2 = "Test"
            MsgBox(String.Concat(str1, str2))
    
        End Sub
    End Class
    Last edited by manhit45; May 21st, 2009 at 08:57 AM.
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width