Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Tuesday, 13 March 2012

vb.net string concat() ?


How to string concat() in vb.net?
I this tutorial you can learn how to cocat two given string (concat means combine two specified strings)
Syntax:
String.cocat(string  str1,string str2) As string
Ex: str.concat(str1,str2)
It will returns combine of two string
 To do this program following steps to be followed
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop two label, textbox, and one button
Label1.textà1st string
Label2.textà2nd string
Buttonàcheck
Step4:
Copy and paste the following code
Public Class Form1

    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        Dim firststring As String = TextBox1.Text
        Dim secondstring As String = TextBox2.Text
        MessageBox.Show(String.Concat(TextBox1.Text, TextBox2.Text))
    End Sub
End Class

 Output:


vb.net string Endswith()?


How to string Endswith() in vb.net?
I this tutorial you can learn how to check the string ends with (check string is ends with some word or not) specified string
Syntax:
String.endswith(string  end_word) As boolean
Ex: str.endswith(“ program”)
It will returns “program” is the endwith() str string. It will shows as true or false
 To do this program following steps to be followed
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop two label, textbox, and one button
Label1.textà1st string
Label2.textà2nd string
Buttonàcheck
Step4:
Copy and paste the following code
Public Class Form1

    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        Dim firststring As String = TextBox1.Text
        Dim secondstring As String = TextBox2.Text
        If firststring.EndsWith(TextBox2.Text) = True Then
            MessageBox.Show("the first string is endswith   "& TextBox2.Text)
        Else
            MessageBox.Show("the first string is not endswith  "& TextBox2.Text)

        End If
    End Sub
End Class


 Output:


Monday, 12 March 2012

vb.net string split() ?


How to string split() in vb.net?
I this tutorial you can learn how to split string (split the string between two words)
Syntax:
String.split(“”)
Ex: str = string.char(hello this vb.net prrogram)
It will returns “hello”,” this”,” vb.net”,” prrogram”
 To do this program following steps to be followed
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop one label, textbox, and one button
Label1.textà1st string
Buttonàcheck
Step4:
Copy and paste the following code
Public Class Form1
    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click

        Dim st_strng As String = TextBox1.Text
        Dim strArr() As String
        Dim count As Integer

        strArr = st_strng.Split(" ")
        For count = 0 TostrArr.Length - 1
            MsgBox(strArr(count))
        Next

    End Sub
End Class
 Output:

vb.net string char()?


How to string char() in vb.net?
I this tutorial you can learn how to get char from string declared (get char)
Syntax:
String.char(string str,char str2)
Here : Stràfisrt string
Str2àget char
Charàchar data type
String à string data type
Ex: str = string.char(3)
The char at 3 position will get into str  
 To do this program following steps to be followed
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop two label, textbox, and one button
Label1.textà1st string
Label2.textà2nd string
Buttonàcheck
Step4:
Copy and paste the following code
Public Class Form1
     Private Sub Button1_Click(ByValsender As System.Object, ByVal e AsSystem.EventArgs) HandlesButton1.Click
         Dimststring As String= TextBox1.Text
        Dim getchar As Char
        getchar = ststring.Chars(TextBox2.Text)
      
        MessageBox.Show(getchar)

    End Sub
End Class





 Output:

vb.net string compare()?


How to string compare() in vb.net?
I this tutorial you can learn how to compare two given string (comparison in numbers(integer format)) , syntax for comapare
String.compare(string str,string str2,boolen as integer)
Here : Stràfisrt string
Str2àsecond string
Boolenàtrue or false
String à string data type
Ex: str = string.compare(str1,str2)
To check str1>str2=greater than zero
Str2>str1= less than zero
Str1=str2=zero
  To do this program following steps to be followed
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop two label, textbox, and one button
Label1.textà1st string
Label2.textà2nd string
Buttonàcheck
Step4:
Copy and paste the following code
Public Class Form1
   
    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        Dim ststring As String = TextBox1.Text
        Dim ndbstring As String = TextBox2.Text
        Dim result_in_integer AsInteger
        'result_in_integer = String.Compare(TextBox1.Text, TextBox2.Text)
        'MessageBox.Show(result_in_integer)
        result_in_integer = String.Compare(TextBox1.Text, TextBox2.Text, True)
        MessageBox.Show(result_in_integer)


    End Sub
End Class



 Output:


vb.net string contains()?


How to string contains() in vb.net?
I this tutorial you can learn how to check string contains (check the given string is there are not) or not, syntax for to check string is
String.contains(string str)
Here : Stràgiven string
String à string data type
Ex: str = string.contains(example)
To check word “example” whether there or not
  To do this program following steps to be followed
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop two label, textbox, and one button
Label1.textà1st string
Label2.textà2nd string
Buttonàcheck
Step4:
Copy and paste the following code
Public Class Form1
   
    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        Dim ststring As String = TextBox1.Text
        Dim ndbstring As String = TextBox2.Text
        If ststring.Contains(TextBox2.Text) Then
            MessageBox.Show("the given string is in 1st tstring: ")
        Else
            MessageBox.Show("the given string is not there in 1st string:")
        End If
       
    End Sub
End Class



 Output:

vb.net string copyto()t?


How to string copyto() in vb.net?
I this tutorial you can learn how to string copy to (copy one string to another one),the syntax of string copy is string.copy(string str)
Here : Stràgiven string
String à string data type

Ex: str = string.copy(str1)
Copy the str1 string into str2

  To do this program following steps to be followed
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop two label, textbox, and one button
Label1.textà1st string
Label2.textà2nd string
Buttonàcopy
Step4:
Copy and paste the following code
Public Class Form1
   
    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        Dim ststring As String = TextBox1.Text
        Dim ndbstring As String
        ndbstring = String.Copy(ststring)
        TextBox2.Text = ndbstring
    End Sub
End Class


 Output:


vb.net string equals()?


How to string equals() in vb.net?
I this tutorial you can learn how to get a string equals (compare to string)  declare first string and second string and compare using if condition  
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop two label, textbox, and one button
Label1.textà1st string
Label2.textà2nd string
Buttonàcheck
Step4:
Copy and paste the following code
    Public Class Form1
   
    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        Dim ststring As String = TextBox1.Text
        Dim ndbstring As String = TextBox2.Text
        If String.Equals(ststring, ndbstring) Then
            MessageBox.Show("string are equals")
        Else
            MessageBox.Show("strings are not equals")
        End If

    End Sub
End Class

 Output:

vb.net get string length?


How to get string length in vb.net?
 In this tutorials you can learn how to get string length in by use length () sign. The length of string in integer number
To make this go to below steps
Step1:
Start Microsoft visual studio 2010
Step2:
File new àwindows forms application àRename it as you wish then form drag and drop button. Double click the button and copy and paste code .
Step3:
 Code:
Public Class Form1

    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        Dim textstring As String
        textstring = TextBox1.Text
        MessageBox.Show("the length of string:  " & textstring.Length())
    End Sub
End Class

Output:






vb.net string indexof() ?



I this tutorial you can learn how to get a specified string indexof (string position) in main string to make this program steeps to be followed
Step1:
Open Microsoft visual studio 2010 or any older version also may differ commands
Step2:
Open file new project(ctrl+shift+n)àselect windows form applicationà rename as you wish
Step3:
Drag and drop two label, textbox, and one button
Label1.textàmain string
Label2.textàsub string
Buttonàget
Step4:
Copy and paste the following code
    Public Class Form1
   
    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        Dim mianstring As String = TextBox1.Text
        Dim substring As String = TextBox2.Text
        MessageBox.Show(mianstring.IndexOf(TextBox2.Text))
    End Sub
End Class

Output: