none
How To Use Left, Mid, Right Functions in vb 2010

    Question

  • I'm now making a number-to-text converter and i use the left, mid and the right functions.
    I tried the way my teacher told me and even others, but it doesn't work. Can somebody help me? Thanks


    Thursday, February 07, 2013 11:06 AM

Answers

  • Hi,

    Add one Button

    to a Form and try this example please.>>

    Imports OldVB = Microsoft.VisualBasic
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim exampleString As String = "The quick brown fox."
    
            Dim leftStr As String = ""
            Dim rightStr As String = ""
            Dim midStr As String = ""
    
            leftStr = OldVB.Left(exampleString, 9)
            rightStr = OldVB.Right(exampleString, 10)
            midStr = OldVB.Mid(exampleString, 5, 11)
    
            MessageBox.Show(leftStr, "leftStr = ")
            MessageBox.Show(rightStr, "rightStr = ")
            MessageBox.Show(midStr, "midStr = ")
    
            'The above are still available for those
            'converting from VB6 and earlier versions.
    
            'You could use these instead.
            'Note the capital "T" in "The quick brown fox."
            'is at index position zero (0) in the new functions.
            leftStr = exampleString.Substring(0, 9)
            rightStr = exampleString.Substring(exampleString.Length - 10)
            midStr = exampleString.Substring(4, 11)
    
            MessageBox.Show(leftStr, "leftStr = ")
            MessageBox.Show(rightStr, "rightStr = ")
            MessageBox.Show(midStr, "midStr = ")
    
        End Sub
    End Class


    Regards,

    profile for John Anthony Oliver at Stack Overflow, Q&A for professional and enthusiast programmers

    Click this link to see the NEW way of how to insert a picture into a forum post.

    Installing VB6 on Windows 7

    App Hub for Windows Phone & XBOX 360 developers.


    Thursday, February 07, 2013 11:38 AM

All replies