
- VBA Tutorial
- VBA - Home
- VBA - Overview
- VBA - Excel Macros
- VBA - Excel Terms
- VBA - Macro Comments
- VBA - Message Box
- VBA - Input Box
- VBA - Variables
- VBA - Constants
- VBA - Operators
- VBA - Decisions
- VBA - Loops
- VBA - Strings
- VBA - Date and Time
- VBA - Arrays
- VBA - Functions
- VBA - Sub Procedure
- VBA - Events
- VBA - Error Handling
- VBA - Excel Objects
- VBA - Text Files
- VBA - Programming Charts
- VBA - Userforms
- VBA Useful Resources
- VBA - Quick Guide
- VBA - Useful Resources
- VBA - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
VBA - String Function
The String function fills a string with the specified character for specified number of times.
Syntax
String(number,character)
Parameter Description
Number − A required parameter. An integer value, which would be repeated for a specified number of times against the character parameter.
Character − A required parameter. Character value, which has to be repeated for a specified number of times.
Example
Add a button and add the following function.
Private Sub Constant_demo_Click() msgbox("Line 1 :" & String(3,"$")) msgbox("Line 2 :" & String(4,"*")) msgbox("Line 3 :" & String(5,100)) msgbox("Line 4 :" & String(6,"ABCDE")) End Sub
When you execute the above function, it produces the following output.
Line 1 :$$$ Line 2 :**** Line 3 :ddddd Line 4 :AAAAAA
vba_strings.htm
Advertisements