Im mearling looking for guidance, not someone to do the code for me, i just started coding vb a couple of days ago, ive odne my hello world, i even made a form that works with an access database, but now the next task is to get a 3 digit date and ascending 3 digit number to be spawned each time the form is opend, to assign it a name so to speak.
Im also curious as to how i am going to convert the date into a 3 digit format. month then day
so today being: 611
like i said im looking for guidance, this isnt for homework, for me to see if i can make something, although i will say, im really getting into this.
Newbie, Looking for guidance3 digit date + 3 digit assigned number
Page 1 of 1
3 Replies - 571 Views - Last Post: 11 June 2008 - 04:20 AM
Replies To: Newbie, Looking for guidance
#3
Re: Newbie, Looking for guidance
Posted 10 June 2008 - 08:36 AM
well ive come up with this, but i now need to figure out how to add 3 more numbers to it, based on an access database id i would think would be the easiest way.
Dim result As String = Now.Month.ToString + Now.Day.ToString Me.TextBox1.Text = result
#4
Re: Newbie, Looking for guidance
Posted 11 June 2008 - 04:20 AM
Im also curious as to how i am going to convert the date into a 3 digit format. month then day
so today being: 611
DerianWeidman,
You say you are looking for a "3 digit date" with an "ascending 3 digit number".
Using the code you provided, you may have some issues with the length of the result.
For today "11 June" it works fine as it converts the date to "611". If you were to run this code back on "8 June", the code would only show two digits: "68". If you need a three digit date, you'll have to add some logic to handle the first 9 days of each month. Also, you'll want to think about how you are going to handle dates like "31 December" which will give you a four digit result.
Unless you are required to use a 3-digit date, i would recommend at least a 4-digit date as the easiest method. If a month or day number is less than 9, add a 0. "8 June" becomes "0608", and "31 December" is simply "1231". If this program is going to be used for more than one year, it might be a good idea to include 2 or 4 extra digits for the year "20080611"
For the second part of your question regarding an ascending 3 digit number that will be generated each time the form is opened, this will take some more thought.
If the application is not going to be shutdown, you could just create a variable to store the last number and add to it each time it is needed. For example:
Unfortunately, if the application is closed, then when it is reopened the variable will start over again.
The easiest way to get around this issue would be to log the last number assigned to a textfile, xml, or even to your access database. When you need to assign a new number, you just find the last number, increment it by 1, then replace the old number with the new number in the log.
Good luck!
-Rob
so today being: 611
DerianWeidman,
You say you are looking for a "3 digit date" with an "ascending 3 digit number".
Using the code you provided, you may have some issues with the length of the result.
For today "11 June" it works fine as it converts the date to "611". If you were to run this code back on "8 June", the code would only show two digits: "68". If you need a three digit date, you'll have to add some logic to handle the first 9 days of each month. Also, you'll want to think about how you are going to handle dates like "31 December" which will give you a four digit result.
Unless you are required to use a 3-digit date, i would recommend at least a 4-digit date as the easiest method. If a month or day number is less than 9, add a 0. "8 June" becomes "0608", and "31 December" is simply "1231". If this program is going to be used for more than one year, it might be a good idea to include 2 or 4 extra digits for the year "20080611"
For the second part of your question regarding an ascending 3 digit number that will be generated each time the form is opened, this will take some more thought.
If the application is not going to be shutdown, you could just create a variable to store the last number and add to it each time it is needed. For example:
Public Class Form1 Dim LogIDNum As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'increment the LogID# by 1 LogIDNum = LogIDNum + 1 'display a string of numbers based on month/day and LogID# Dim result As String = Now.Month.ToString + Now.Day.ToString Me.TextBox1.Text = result & LogIDNum End Sub End Class
Unfortunately, if the application is closed, then when it is reopened the variable will start over again.
The easiest way to get around this issue would be to log the last number assigned to a textfile, xml, or even to your access database. When you need to assign a new number, you just find the last number, increment it by 1, then replace the old number with the new number in the log.
Good luck!
-Rob
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|