Results 1 to 2 of 2

Thread: Another Procedure

  1. #1

    Thread Starter
    Lively Member dedub's Avatar
    Join Date
    Dec 2002
    Location
    NC
    Posts
    98

    Another Procedure

    Seeing how you guys are WAY better than me at Procedures could you help me on this one. I have to execute this code in 5 different text boxes. How could I write a call to simplify everthing. The only thing different for each one is the text changes from text1.text to text2.text...ect. In other words, I know how to create the procedure to call this code, what I dont know how to do is change where the text1.text changes to text2.text ie... I cant call this code from Text2_MouseDown(.......

    VB Code:
    1. Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2. On Error GoTo handler
    3. If Button = vbRightButton Then
    4. Dim subtract As Integer
    5. subtract = InputBox("Please enter the amount you wish to subtract", "Subtract")
    6. Text1.Text = Text1.Text - subtract
    7. recalc'this is another procedure Im calling, ...disreguard
    8. End If
    9. handler:
    10. Select Case Err.Number
    11.     Case 13
    12.         MsgBox "Please enter a number"
    13. End Select
    14.  
    15. End Sub
    Last edited by dedub; Nov 2nd, 2003 at 10:04 PM.
    R.L.T.W. A+, NET+, CCNA

    Doin' my best

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    This is very similar to your other question.

    VB Code:
    1. Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     MouseDown Text1, Button
    3. End Sub
    4.  
    5.  
    6. Public Function MouseDown(txt As TextBox, btn As Integer)
    7.     Dim subtract As Integer
    8.    
    9.     On Error GoTo handler
    10.    
    11.     If btn = vbRightButton Then
    12.         subtract = InputBox("Please enter the amount you wish to subtract", "Subtract")
    13.         txt.Text = txt.Text - subtract
    14.         'recalc 'this is another procedure Im calling, ...disreguard
    15.     End If
    16. handler:
    17.     Select Case Err.Number
    18.         Case 13
    19.             MsgBox "Please enter a number"
    20.     End Select
    21.  
    22. End Function

Posting Permissions

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



Click Here to Expand Forum to Full Width