micropathic Posted November 30, 2003 Posted November 30, 2003 Hi, I am trying to simulate clicking a command button I've named "sync" by using the following code: Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load '*************This Part Works Correctly***************** Dim nBufferKey, nBufferSubKey As Integer Dim nBufferDATA As String nBufferDATA = Space(256) RegOpenKey(LOCALMACHINE, "SOFTWARE\Microsoft\Windows CE Services", nBufferKey) RegOpenKey(nBufferKey, "AutoStartOnConnect", nBufferSubKey) RegQueryValueEx(nBufferSubKey, "Rubber Stamped Sync", 0, REG_SZ, nBufferDATA, Len(nBufferDATA)) 'MsgBox(nBufferDATA) txtChkBx.Text = nBufferDATA Dim MyStr As String Dim myStr2 As String myStr2 = Trim(txtChkBx.Text) MyStr = VB.Right(myStr2, 8) '***********End Of Code That Works correctly************** If Microsoft.VisualBasic.Command() = "rssyncme" Then '*****This is working and IS retruring "rssyncme" as the command line argument********** Form1.DefInstance.Sync.PerformClick() '*************This seems to be problematic for some reason!!!********** End If End Sub Getting the "rssyncit" string as the command line argument is working correctly. Clicking the button "sync" manually works fine, but when trying to automate it as shown in the code above, for some reason it doesn't work. Any help would be greatly appreciated!!!:) Quote
Administrators PlausiblyDamp Posted November 30, 2003 Administrators Posted November 30, 2003 Could you not just call the button's click event manually? i.e. If Microsoft.VisualBasic.Command() = "rssyncme" Then '*****This is working and IS retruring "rssyncme" as the command line argument********** Sync_Click(nothing,nothing) End If Has this code been generated by the Upgrade wizard by any chance? If so you may want to replace some of the VB6 functions with their .Net equivalent. Use myStr2.substring(...) instead of VB.Right and system.Environment.CommandLine instead of Microsoft.VisualBasic.Command() for example Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
micropathic Posted November 30, 2003 Author Posted November 30, 2003 (edited) Thanks!! that worked! And yes, a lot of the code in this project was generated by the upgrade wizard. This is my first project in .net and I'm just now learning the ins and outs of the change in the language. I figured upgrading this project from its old vb6 version would be a good way to learn .net and so far thanks to the help of people such as yourself it hasn't been all that difficult. Thanks! Edited November 30, 2003 by micropathic Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.