Reputation: 305
I declared a string s like this
Dim s As String=""
And I am trying to build a keylogger that e-mails String "s" by concatenating keystrokes. A sample code snippet is as follows
Dim hotkey5 As Boolean
hotkey5 = GetAsyncKeyState(Keys.E)
If hotkey5 = True Then
String.Concat(s, "E")
End If
But nothing is getting concatenated to String s. Why is that so?
Upvotes: 0
Views: 212
Reputation: 60
Dim hotkey5 As Boolean
hotkey5 = GetAsyncKeyState(Keys.E)
If hotkey5 = True Then
s+="E"
End If
VB.Net provides an ability to add or concatenate two strings using +
operator. It also can be used many way.
VB.Net provides an ability to add or concatenate two strings using +
operator. It also can be used many way.
Let Dim Valu1 as String=”1”
and Dim Valu2 as String=”2”
. Then Dim concatenate = Valu1+Valu2
. So the value will be ”12”
. Or we can, Dim concatenate = Valu2+Valu1
. Then the value will be ”21”
. So it is pretty simple as that
Upvotes: -1
Reputation: 65555
In .net Strings are immutable. So you need a new string to hold the results of the the concatenation - which is the concatenated string.
Dim hotkey5 As Boolean
hotkey5 = GetAsyncKeyState(Keys.E)
If hotkey5 = True Then
s= String.Concat(s, "E")
End If
Upvotes: 2