Gopher2011
Well-known member
Can anyone look at this code and see how i can speed it up?
Its calling a sub to count commas in long string.
Calling part
The sub. This takes about 0.7 of a second to count 20 commas in string _InMessToAction. Was hoping to get it down to 0.1... if at all possible..
example string = _InMessToAction = "0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000"
Its calling a sub to count commas in long string.
Calling part
VB.NET:
[COLOR=#222222][FONT=Times New Roman] 'Sort the incomming messages[/FONT][/COLOR]
[COLOR=#222222][FONT=Times New Roman] Dim count_Coma As Integer = CountCharacter(_InMessToAction, ","c)[/FONT][/COLOR]
The sub. This takes about 0.7 of a second to count 20 commas in string _InMessToAction. Was hoping to get it down to 0.1... if at all possible..
example string = _InMessToAction = "0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000"
VB.NET:
[COLOR=#222222][FONT=Times New Roman] Public Function CountCharacter(ByVal value As String, ByVal ch As Char) As Integer[/FONT][/COLOR]
[COLOR=#222222][FONT=Times New Roman] Dim cnt As Integer = 0[/FONT][/COLOR]
[COLOR=#222222][FONT=Times New Roman] For Each c As Char In value[/FONT][/COLOR]
[COLOR=#222222][FONT=Times New Roman] Debug.Write(".")[/FONT][/COLOR]
[COLOR=#222222][FONT=Times New Roman] If c = ch Then cnt += 1[/FONT][/COLOR]
[COLOR=#222222][FONT=Times New Roman] Next[/FONT][/COLOR]
[COLOR=#222222][FONT=Times New Roman] Return cnt[/FONT][/COLOR]
[COLOR=#222222][FONT=Times New Roman] End Function[/FONT][/COLOR]