Hi!
I am trying to create a code that counts characters in textbox(including whitespaces) and checks if it contains specific characters: |^€{}[]~
All these symbols mentioned above will increase the count by 2. Every other symbol/character will increase the count by 1.
I think my code I created is too...amateur. Is there another way to do this ?
This is the code I have so far:
Thanks in advance! ;)
I am trying to create a code that counts characters in textbox(including whitespaces) and checks if it contains specific characters: |^€{}[]~
All these symbols mentioned above will increase the count by 2. Every other symbol/character will increase the count by 1.
I think my code I created is too...amateur. Is there another way to do this ?
This is the code I have so far:
Code:
' Symbols that take up 2 character space: |^€{}[]~
Dim c As Integer
Dim result As Integer = 0 'The number of counted characters
For c = 1 To Len(TextBox1.Text)
If Mid(TextBox1.Text, c, Len("€")) = "€" Then
result += 2
ElseIf Mid(TextBox1.Text, c, Len("|")) = "|" Then
result += 2
ElseIf Mid(TextBox1.Text, c, Len("^")) = "^" Then
result += 2
ElseIf Mid(TextBox1.Text, c, Len("{")) = "{" Then
result += 2
ElseIf Mid(TextBox1.Text, c, Len("}")) = "}" Then
result += 2
ElseIf Mid(TextBox1.Text, c, Len("[")) = "[" Then
result += 2
ElseIf Mid(TextBox1.Text, c, Len("]")) = "]" Then
result += 2
ElseIf Mid(TextBox1.Text, c, Len("~")) = "~" Then
result += 2
Else
result += 1
End If
Next
Me.Label1.Text = resultThanks in advance! ;)