VB6 Code Help


Closed Thread
Results 1 to 6 of 6

Thread: VB6 Code Help

Hybrid View

  1. #1
    Join Date
    Feb 2003
    Posts
    432

    Default

    Quote Originally Posted by charudatt
    I am facing a problem with the VB code. I cannot figure out how to program a command button (in VB6) to keep sending a stream of string when the comannd button is kept pressed. At present I can only program in a way that it sends a string only once. I have 4 command buttons for 4 direction and I am interested in Momentary action for these Command Buttons.
    I did something similar for controlling a Video Conferencing camera.

    Instead of using the Click event for the button....

    1. Create a timer for each button and have the timer send a command each time it expires.

    2. Use the MouseDown event to enable the timer

    3. Use the MouseUp event to disable the timer.

    The end result is that for the duration of the button press, your program will send the command every x milliseconds depending on what you set x to be.

    You can get clever and include a counter as well so that you start off with one command every 200mS giving slow control but after "n" steps you decrease the time period so that the movement accellerates either gradually... 200, 190, 180, 170 etc or rapidly 200, 200, 200, 50, 50, 50 etc

    Hope that helps
    Keith

    www.diyha.co.uk
    www.kat5.tv

  2. #2
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161

    Default Thanks !

    Thanks fellas,

    I shall try it out and give my feedback. Good tip of using a Timer.

    regards

  3. #3
    mazmoiz's Avatar
    mazmoiz Guest

    Smile X-Y Movement of the arm using mouse !!!

    Hello !!
    May be this piece of code can help u in sending a stream of strings as u want !! (X-Y Movement) and continous streaming !!!

    Send the values of X and Y text boxes to the COM port.
    U have to modify this code as per ur requirements !!

    here the values of textboxes ranges from 0-100 in both the directions
    You have to set the value between 25 to 225 if using Servo motors !!

    the arm movements will follow the mouse movements in x-y position.

    (Note: here code only shows X-Y movements !!! and it doesnt contain
    COM event programming !! You have to use COM control for
    sending textbox values to the port)

    I hope u'll find this code helpful and useful for your project !!
    Regards

    Mazhar Haque


    PLS have a look at the attached ZIP file !!!
    --------------------------------------------------------------------------

    Private Sub Command1_Click()
    xl.Visible = True
    yl.Visible = True
    Picture2.Visible = False

    End Sub


    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
    xl.Visible = False
    yl.Visible = False
    Picture2.Visible = True
    End If
    End Sub

    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim intx As Integer
    Dim inty As Integer

    xl.Y1 = Y
    xl.Y2 = Y
    intx = Abs(Y - 100)
    xt.Text = intx


    yl.X1 = X
    yl.X2 = X
    inty = Abs(X - 100)
    yt.Text = inty

    End Sub
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216

    Wink Nice Code!

    Nice code mazmoiz,
    Who needs a joystick? I know I can think of some applications this code could be useful.... with a little modification. Koodos
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  5. VB6 Code Help
    By charudatt in forum Code Examples
    Replies: 5
    Last Post: - 14th July 2006, 21:41

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts