Use of Strings


Private Sub VBAStringFunctionExample()

'VBA macro Code program for understand the function of string

'Note: Enter on Sheet1 Column B3 (Raw No 3 nd Column no 2)
'first Name
'Length of first Name
'Last Name
'Length of Last Name
'All UpperCase
'All lowercase
'Concatenation
'Code start

Dim Username As String
Dim Firstname As String
Dim Lastname As String
Dim Strlen As Integer
Dim spaceloc As Integer

Username = InputBox("Enter your First and Last name.", "Username")

spaceloc = InStr(1, Username, " ")
Firstname = Left(Username, spaceloc - 1)
Sheets("Sheet1").Activate
Cells(3, "C").Value = Firstname
Strlen = Len(Firstname)
Cells(4, "C").Value = Strlen
Strlen = Len(Username)
Lastname = Mid(Username, spaceloc + 1, Strlen - spaceloc)
Cells(5, "C").Value = Lastname
Strlen = Len(Lastname)
Cells(6, "C").Value = Strlen
Cells(7, "C").Value = UCase(Username)
Cells(8, "C").Value = LCase(Username)
Cells(9, "C").Value = Lastname & ", " & Firstname

End Sub

Sub VBAStringFunctionExample()
'Note: Enter on Sheet1 Column B3 (Raw No 3 nd Column no 2)
'first Name
'Length of first Name
'Last Name
'Length of Last Name
'All UpperCase
'All lowercase
'Concatenation
'Code start

Dim Username As String
Dim Firstname As String
Dim Lastname As String
Dim Strlen As Integer
Dim spaceloc As Integer

Username = InputBox("Enter your First and Last name.", "Username")

spaceloc = InStr(1, Username, " ")
Firstname = Left(Username, spaceloc - 1)
Sheets("Sheet1").Activate
Cells(3, 4).Value = Firstname
Strlen = Len(Firstname)
Cells(4, 4).Value = Strlen
Strlen = Len(Username)
Lastname = Mid(Username, spaceloc + 1, Strlen - spaceloc)
Cells(5, 4).Value = Lastname
Strlen = Len(Lastname)
Cells(6, 4).Value = Strlen
Cells(7, 4).Value = UCase(Username)
Cells(8, 4).Value = LCase(Username)
Cells(9, 4).Value = Lastname & ", " & Firstname


Sub VBAStringFunctionExample()

'Note: Enter on Sheet1 Column B3 (Raw No 3 nd Column no 2)
'first Name
'Length of first Name
'Last Name
'Length of Last Name
'All UpperCase
'All lowercase
'Concatenation
'Code start


Dim Username As String
Dim Firstname As String
Dim Lastname As String
Dim Strlen As Integer
Dim spaceloc As Integer

Username = InputBox("Enter your First and Last name.", "Username")

spaceloc = InStr(1, Username, " ")
Firstname = Left(Username, spaceloc - 1)
Sheets("Sheet1").Activate
Cells(3, 4).Value = Firstname
Strlen = Len(Firstname)
Cells(4, 4).Value = Strlen
Strlen = Len(Username)
Lastname = Mid(Username, spaceloc + 1, Strlen - spaceloc)
Cells(5, 4).Value = Lastname
Strlen = Len(Lastname)
Cells(6, 4).Value = Strlen
Cells(7, 4).Value = UCase(Username)
Cells(8, 4).Value = LCase(Username)
Cells(9, 4).Value = Lastname & ", " & Firstname

End Sub


Comments

Popular posts from this blog

TDS Calculation System

VBA - Additional Controls Dialog Box "MISSING"

Loan EMI Calculator Dashboard