VBA/Excel/Access/Word/String Functions/Mid

Материал из VB Эксперт
Перейти к: навигация, поиск

Mid() returns Any portion of a string

 
Sub midDemo()
    Dim userName As String
    Dim firstName As String
    Dim spaceLoc As Integer
    Dim strLength As Integer
    Dim lastName As String
        
    userName = " First Last"
    spaceLoc = InStr(1, userName, " ")
    firstName = Left(userName, spaceLoc - 1)
    strLength = Len(firstName)
    lastName = Mid(userName, 1, 5)
    
    Debug.Print lastName
End Sub



Mid() Returns a substring from inside a string.

 
Sub strDemo7()
   Debug.Print Mid("Test", 2, 2)
End Sub