I am trying to input the function key that a user has selected from a ComboBox (containing the function keys F1~F12 as options) into the GetAsyncKeyState(). However, since the ComboBox_StartHotkey.Text is a string, it cannot be converted into Long data type needed for the GetAsyncKeyState() function. I have tried Conversion and Parse Methods but what I try doesn't seem to work. Anyone know how to effectively convert a String (such as F6) into a Long data type for using in the GetAsyncKeyState() function in this case?Code:If CheckBox_StartHotkey.Checked = True Then If Not ComboBox_StartHotkey.Text = Nothing Then Dim StartHotKey As Boolean StartHotKey = GetAsyncKeyState(ComboBox_StartHotkey.Text) If StartHotKey = True Then StartActions() End If End If End If
I used the tried to use the ItemData property to hold the Key Code representing the Function Key...
...then change the original code to...Code:Dim intCount As Integer For intCount = 1 To 12 ComboBox_StartHotkey.AddItem "F" & Cstr(intCount) ComboBox_StartHotKey.ItemData(ComboBox_StartHotKey.NewIndex) = 105 + intCount Next intCount
...but this code is not for my version of Visual Basic. Anyone know how to convert it? Thanks for helping!Code:If CheckBox_StartHotkey.Checked = True Then If ComboBox_StartHotkey.ListIndex <> -1 Then Dim StartHotKey As Boolean StartHotKey = GetAsyncKeyState(ComboBox_StartHotkey.ItemData(ComboBox_StartHotKey.ListIndex)) If StartHotKey = True Then StartActions() End If End If End If




Reply With Quote