Results 1 to 4 of 4

Thread: [RESOLVED] Counting

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] Counting

    I have combo1.text with value 1. I want to save three time only. I don't want the messagebox asking me when the count reach 3. How to do that?

    Code:
     
    MsgBox "Records Save",vbInformation, "Info"
    If MsgBox("You Want to add record : "& Combo1.text & " ?",vbQuestion + vbYesNo) = vbYes Then

  2. #2
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: Counting

    Add a counter variable to your code and each time you save add 1 to the counter.
    When the variable = 3 then don't allow the user to save again.

    Code:
    Private ctr As Long
    
    If Not ctr = 2 '(2 because we start at 0)
         MsgBox "Records Save",vbInformation, "Info"
         If MsgBox("You Want to add record : "& Combo1.text & " ?",vbQuestion + vbYesNo) = vbYes Then
              ctr = ctr + 1
    
              'your code here
    
         End If
    End If
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Counting

    If Not ctr = 2 '(2 because we start at 0)


    You not state the counter start with 0 ?

  4. #4
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: Counting

    Quote Originally Posted by matrik02
    If Not ctr = 2 '(2 because we start at 0)


    You not state the counter start with 0 ?
    You can start the counter at anything you want, but if you don't state anything it starts at zero by default
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

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