Has anyone been able to successfully pull a value back to HS3 from an Hstouch textbox? i can do it with drop downs and text elements but no matter what I try with a textbox i just get an error.
Announcement
Collapse
No announcement yet.
Pull a value from Textbox in Hstouch
Collapse
X
-
First I created hidden text elements. For the purpose of demonstration, they are un-hidden here. I allowed presses on the text box and when released, it first sets the text element as seen below - in this case, it's called UserID:
Then it passes the element UserID string to a script, in this case EditUserPhone.vb
Then the script receives the passed string in parm(0), and parm(1) if there's a second variable being passed, then manipulates a virtual device in HS3:
Code:'HS3 Script 2019-01-15 JG Sub Main(ByVal parm As Object) Dim inputphone, UserNo, UserPhone, UserPass inputphone = parm(1).ToString ' Get new user name from HSTouch UserNo = parm(0).ToString ' Get new user number from HSTouch UserPhone = "User" & UserNo & "Phone" UserPass = "User" & UserNo & "Phone" If Len(inputphone) <>10 Then hs.Speak("Phone Number must be at 10 characters") hs.SaveINISetting("Users", UserPhone, "N/A", "configfile.ini") ' hs.SetDeviceStringByName(UserPhone,"Off",true) Else hs.SaveINISetting("Users", UserPhone, inputphone, "configfile.ini") ' hs.SetDeviceStringByName(UserPhone,inputphone,true) hs.Speak("User " & UserNo & " Phone changed sucessfully") hs.writelog("Security",CStr("User " & UserNo & " Phone changed to: " & inputphone)) End If End Sub
Hope this helps.
Jeff
Comment
-
Ugh I keep getting the same error every time even setting it up like that.
Running script Cookie.vb :Exception has been thrown by the target of an invocation.->Does entry point Main exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Obj ect obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Scheduler.clsRunVBNetScript.ExecuteScript()
Comment
-
I'm sorry, but I am not familiar with the error, maybe one of the more experienced HS3 people on here can help, but, this could be the issue...
My example was for passing 2 parameters from HSTouch, how many are you sending?
If you copied my code exactly and you are only sending one parameter to the script, it will fail. The first parameter is parm(0), the second is parm(1), and so on. If you only have one parameter then delete the parm(1) line.
Comment
-
nah thats not it i tried passing just one and two just to be sure my script literally just assigning value to a variable then not doing anything right now. Everything else works great just missing this one piece.
Originally posted by jgreenberg01 View PostI'm sorry, but I am not familiar with the error, maybe one of the more experienced HS3 people on here can help, but, this could be the issue...
My example was for passing 2 parameters from HSTouch, how many are you sending?
If you copied my code exactly and you are only sending one parameter to the script, it will fail. The first parameter is parm(0), the second is parm(1), and so on. If you only have one parameter then delete the parm(1) line.
Comment
Comment