none
VB8 CODE

    Question

  • I am trying to write code to do the following:

    I want when I use a checkbox setting to TRUE that a unique numbet must be generated that works as follows:

    BMG/current month/current year/1001(this number must increment with 1 (one) every time you add a new item to the database. I am using Access 2007.

    If anybody out there can help i will be very much obliged.

    regards out of a sunny South Africa.

     

     

     


    NuutVB
    Sunday, December 05, 2010 5:00 PM

Answers

  • Hi all,

    Like a homework :)!, but you could try below simple code for generating the code:

      Private srno As Integer = 1001
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
        If CheckBox1.Checked Then
          Dim str As String = "BMG/" & Now.Month.ToString("D2") & "/" & Now.Year & "/" & srno
          srno += 1
          Console.WriteLine(str)
        End If
      End Sub
    

    Sincerely,
    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Are you looking for a typical code sample? Please download All in One Code Framework !

    如果有回复帮助并解决了您的问题,请点击 “标记为答复”,如果没有没有帮助,请随时点击“取消答复标记”
    你在为寻找代码示例而苦恼吗?赶快来下载 All in One Code Framework 微软一站式代码框架 吧!
    • Marked as answer by NuutVB Thursday, December 09, 2010 11:38 AM
    Thursday, December 09, 2010 10:50 AM
    Moderator

All replies

  • Well this sounds a bit like homework so I'll try to just point you in the right direction.  Have you been looking at events yet?  The checkbox control has a CheckedChanged event that you can handle:  http://msdn.microsoft.com/en-us/library/system.windows.forms.checkbox.checkedchanged(v=VS.90).aspx

    Within that event handler you can inspect the Checked property and increment your code accordingly.

    Your original question doesn't really say exactly what you want help with.  If I haven't answered you then I suggest you be more specific with your next question. 

    Monday, December 06, 2010 12:51 AM

  • I think Dig-Boy has provided a good answer.  I just wanted to say that my initial take on the question was that you wanted the checkbox to control the generation of the string, and that when the check is true, the numeric would come from the database.  What I did not understand though is what the string should look like if the check was false.  My assumption was that a button click acted on the form to generate the name.
     
    It may be that your question comes down to the need to get the highest sequence number of all items in the database.  If so, please ask that question, which should lead to being able to incriment the value and get the string.  I'm still then left wondering why the checkbox is necessary.
     
    So you can see that there are two resonable interpretations when you are not specific in what you are looking for in the post.

    --
    Mike
    Monday, December 06, 2010 2:26 AM
  • Well this sounds a bit like homework so I'll try to just point you in the right direction.  Have you been looking at events yet?  The checkbox control has a CheckedChanged event that you can handle:  http://msdn.microsoft.com/en-us/library/system.windows.forms.checkbox.checkedchanged(v=VS.90).aspx

    Dig boy,

    That page is for VB9 (the number represent the language version of VB, which is the latest version because the product version '10 and the language version is 10 probably for the first time the same) VB8 represents the language version in VB2005. 

    The only thing which is different is that Framework 2 can only be used in this case.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.checkbox.checkedchanged(v=VS.80).aspx

    Just for your information as MVP 

    :-)

     


    Success
    Cor
    Monday, December 06, 2010 7:13 AM
  • Morning.Thanx for the reply.

    I am learning myself to use VB8 and am trying to store information in an Access 2007 for now.

    I am running a storeroom and we have a lot of different electrical and other items in the store that has no serial numbers. (Old stuff before my time)

    I want the system to generate an unige number when I want ti use it - therefore the check box idea. some of the items do have serial numbers on them.

    The generated number must always start with BMG(Company Initials) then the month the number was generated, then the current year and lastly the actual serial number, something like this BMG/12/2010/1001.

    The month must change on the first day of the month

    the year on the first day of the new year

    and the last four digits everytime a number is generated when the setting is true

    Hope this explains my problem better.

    thanx again for the help so far.

     


    NuutVB
    Monday, December 06, 2010 8:02 AM
  • If you are learning yourself a program language like Visual Basic, than start with giving the correct names.

    VB8 is a language code version which is seldom used and that is included in the product Visual Basic 2005, are you sure you want only Framework 2.0 answers and not Framework 3.5 which is included in product version 2008?

     


    Success
    Cor
    Monday, December 06, 2010 8:12 AM
  • I am currently using Visual Basic 2008 and yes it must be the answers for Framework 3.5. Sorry about that. Learning curve here...

    thanx

     


    NuutVB
    Monday, December 06, 2010 8:25 AM
  • @Cor:  That page is for VB9 (the number represent the language version of VB, which is the latest version because the product version '10 and the language version is 10 probably for the first time the same) VB8 represents the language version in VB2005. 

    The only thing which is different is that Framework 2 can only be used in this case.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.checkbox.checkedchanged(v=VS.80).aspx

    Just for your information as MVP 

    ---------------------------------------------------------------------

    @NuutVB:  I am currently using Visual Basic 2008 and yes it must be the answers for Framework 3.5. Sorry about that. Learning curve here...

    thanx


    Oh - SLAM!!  You see Cor, as an MVP I have gained the power of anticipating mistaken information.  I'm surprised you haven't developed it yet  ;) 

    Ha Ha!  Really though, I should have have notice that since it was prominently displayed in the thread title.  Definitely my bad.  All the same, I don't believe the CheckedChanged event has changed at all across any of the framework versions.

     

     

    Monday, December 06, 2010 2:43 PM
  • Hi all,

    Like a homework :)!, but you could try below simple code for generating the code:

      Private srno As Integer = 1001
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
        If CheckBox1.Checked Then
          Dim str As String = "BMG/" & Now.Month.ToString("D2") & "/" & Now.Year & "/" & srno
          srno += 1
          Console.WriteLine(str)
        End If
      End Sub
    

    Sincerely,
    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Are you looking for a typical code sample? Please download All in One Code Framework !

    如果有回复帮助并解决了您的问题,请点击 “标记为答复”,如果没有没有帮助,请随时点击“取消答复标记”
    你在为寻找代码示例而苦恼吗?赶快来下载 All in One Code Framework 微软一站式代码框架 吧!
    • Marked as answer by NuutVB Thursday, December 09, 2010 11:38 AM
    Thursday, December 09, 2010 10:50 AM
    Moderator
  • Thanx will try the code

     


    NuutVB
    Thursday, December 09, 2010 11:39 AM