Visual Basic .NET Forums  

Go Back   Visual Basic .NET Forums > VB.NET > Windows Forms

Windows Forms Discussion related to Winforms application development

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-23-2008, 3:33 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2008
Posts: 21
Reputation: 13
stresss is on a distinguished programming path ahead
Default How to Auto Generate ID number

Hi all!

I have a question about how to auto generate the next id number.

In my form, I have 5 radiobuttons and one Message ID textbox. When I click on the first radiobutton, the number 1000 will appear in the MsgID textbox, so what I want to achieve is when 1000 is used, and when i close my form and open again, and select the 1st radiobutton, it will show 1001 instead of 1000. Also when I select the 2nd radiobutton, the number 2000 will appear in the MsgID textbox, so likewise how do I get the next available id when 2000 is used?

Thank you very much in advance!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-23-2008, 4:00 AM
VB.NET Forum Master
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2008
Location: Vienna, Austria
Age: 22
Posts: 337
Reputation: 275
Robert_Zenz master of VB.NETRobert_Zenz master of VB.NETRobert_Zenz master of VB.NETRobert_Zenz master of VB.NETRobert_Zenz master of VB.NETRobert_Zenz master of VB.NETRobert_Zenz master of VB.NETRobert_Zenz master of VB.NETRobert_Zenz master of VB.NET
Default

Hello.

Shall this be kept if the form closes, or if the program closes?
First would a global variable.
Second would put you in the need to save the variable 'somewhere'. You can use My.Settings for this, you could use a XML, INI or plain Textfile for it.

Bobby
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-23-2008, 4:00 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Sep 2008
Age: 33
Posts: 3
Reputation: 0
Shanks is on a distinguished programming path ahead
Default

First you need to decide on where you are going to save the current Id, text file, database, .dat file. Then when you load the form you need to parse what ever file you have decided to use, apply the current number to a session variable and then just increment it each time you push your radio button.

Making any sense??

If not let me know and i'll post some psuedo-code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-23-2008, 4:08 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2008
Posts: 21
Reputation: 13
stresss is on a distinguished programming path ahead
Default

Quote:
Originally Posted by Robert_Zenz View Post
Hello.

Shall this be kept if the form closes, or if the program closes?
First would a global variable.
Second would put you in the need to save the variable 'somewhere'. You can use My.Settings for this, you could use a XML, INI or plain Textfile for it.

Bobby
It shld be kept even when the program closesm, so when the user create a message with ID as 1000, and closes the program, the next time the user opens it, the ID will be 1001 ( that's for the 1st radiobutton). Then the second radiobutton starts from 2000, so if the user select the 2nd radiobutton and create a message, it will start from 2000. The ID is taken from a table and it's the primary key.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-23-2008, 4:10 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2008
Posts: 21
Reputation: 13
stresss is on a distinguished programming path ahead
Default

Quote:
Originally Posted by Shanks View Post
First you need to decide on where you are going to save the current Id, text file, database, .dat file. Then when you load the form you need to parse what ever file you have decided to use, apply the current number to a session variable and then just increment it each time you push your radio button.

Making any sense??

If not let me know and i'll post some psuedo-code.
Yeap it make sense. But I don't know how to use the increment method. It will be better if you can provide some code =). The ID is taken from a table, and it's the primary key. And all the table is saved into that table too.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-23-2008, 4:14 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Sep 2008
Age: 33
Posts: 3
Reputation: 0
Shanks is on a distinguished programming path ahead
Default

Incrementing the variable would be done like so...

Code:
YourVariable += 1
But I get the feeling that, that is not the problem you are asking about. As this is the primary key of your table then you shouldn't need to worry about incrementing it anyway. Hasn' the column got an auto increment feature?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-23-2008, 11:38 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2008
Posts: 21
Reputation: 13
stresss is on a distinguished programming path ahead
Default

Yeap it has an auto increment value of 1. But i want it to be displayed in the textbox. Like if id 1000 is used, then the next available will be 1001 and it will be displayed in the textbox. And if i close the program, and open it again, it will show 1001. Thought of using the incrementing the variable, but i don't know how to implement it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 11:32 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0


For advertising opportunities click here.