I couldn't find any. Is there one? Google didn't help me, because it's case insensitive and thinks I am looking for "basic" commands.
Asked
Active
Viewed 598 times
1
-
2What dialect of basic are you using? – Damien_The_Unbeliever May 02 '13 at 07:55
-
Use LEN(variable$) – eoredson Jul 29 '18 at 03:40
6 Answers
12
Use LEN(expression), where the expression can be any string or string variable
Example:
X = LEN("Jack Daniels") >>> X contains 12
or
strX = "Jack"
X = LEN(strX) >>> X contains 4

ollo
- 24,797
- 14
- 106
- 155

Ivan Stankovic
- 1,602
- 18
- 13
7
All Basic dialects I know of have a len
function that returns the length of a string expression. Examples:
- Apple // Integer basic
- Visual Basic 6
- Visual Basic .NET
- http://www.fact-index.com/b/ba/basic_programming_language.html
In Visual Basic .NET you could also use the .Length
property of the string, but that property behaves differently for the Nothing
value: Len() function vs String.Length property; which to choose?
2
Use the Len
Dim YourString as String
Dim CharCount as Integer
YourString ="MyString"
CharCount = LEN(YourString)
msgbox "There are " & CharCount & " Characters in mystring"

JustGreat
- 551
- 1
- 11
- 26
0
If you mean that you want to count the number of a specific character in a , you can do something like that :
Dim YourString as String
Dim CharCount as Integer
Dim MyChr as Char
Dim chrl as Char
YourString ="MyString"
MyChr ="A"
CharCount = 0
For i = 1 To Len(YourString)
chrl = Mid(YourString, i, 1)
if UCase(chrl) = UCase(MyChr) then
CharCount = CharCount + 1
end if
next i
msgbox "There are " & CharCount & " " & MyChr & " Characters in mystring"

JustGreat
- 551
- 1
- 11
- 26
0
Yes, look at this example:
' Initializes variable.
Dim TestString As String = "Hello World"
' Returns 11.
Dim TestLen As Integer = Len(TestString)
So TestString = Hello World, and the TestLen = 11 because Hello World has 11 characters in it.

Tutorial Nom
- 21
- 1
- 2
- 6
-1
conta = strlen(name_of_variable)
strlen
gives the number of character of variables given an integer

Rory McCrossan
- 331,213
- 40
- 305
- 339