Hello
How can i count the number of comma (",") in a a CSV string: Comma separated String
Any help appreciated
Martin
How to count how many comma in a CSV string [SOLVED]
- TJ
- Posts: 7751
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2228 times
Re: How to count how many comma in a CSV string [SOLVED]
first, find out the length of the string (hint: there is a keyword for that),Hello
How can i count the number of comma (",") in a a CSV string: Comma separated String
Any help appreciated
Martin
then create a loop that cycles the length of the string,
during the cycle through the loop, check each character to see if it is a ",".
Count while you are do the matching.
Re: How to count how many comma in a CSV string
Here is a codefirst, find out the length of the string (hint: there is a keyword for that),Hello
How can i count the number of comma (",") in a a CSV string: Comma separated String
Any help appreciated
Martin
then create a loop that cycles the length of the string,
during the cycle through the loop, check each character to see if it is a ",".
Count while you are do the matching.
Code: Select all
Var:
A (0),
B (1),
Str ("A,B,C,D");
While B <> 0 begin
B= Instr(STR,B,",");
If B <> 0 then begin
A= A+1;
B = B +1;
end;
end;
// A = Number of comma
Code: Select all
Sub Countcomma_2()
Dim a As Integer
Dim Str As String
Dim b As Integer
b = 1
Str = ("A,B,C,D")
While b <> 0
b = InStr(b, Str, ",")
If b <> 0 Then
a = a + 1
b = b + 1
End If
Wend
MsgBox a