473,586 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

increment 4 digit number automatically.. .its urgent

64 New Member
how to increment 4 digit number automatically in vb.net windows appln

for example:

dc0001-----this is first userid
next time i click new button the user id automatically increased to dc0002
likewise

anybody to help me
Mar 27 '07 #1
2 3274
sravi8
4 New Member
use padright for your numeric varaible and cocant with your alphabet variable

eg

Dim IntNumber as integer
Dim StrCode as String


'eg
'IntNumber = 1
'strcode = dc

intnumber = intnumber.Tostr ing.PadRight("0 ",4)
strcode = strcode & intnumber

i hope it will help you
Mar 27 '07 #2
prabunewindia
199 New Member
how to increment 4 digit number automatically in vb.net windows appln

for example:

dc0001-----this is first userid
next time i click new button the user id automatically increased to dc0002
likewise

anybody to help me

Dim id As String = TextBox1.Text 'the last id no is in textbox1. you can get it
from database

Dim number As Integer = id.Substring(2, 4)
If (number < 9) Then
TextBox1.Text = id.Insert(5, (number + 1).ToString()). Remove(6)

ElseIf (number < 99) Then
TextBox1.Text = id.Insert(4, (number + 1).ToString()). Remove(6)
ElseIf (number < 999) Then
TextBox1.Text = id.Insert(3, (number + 1).ToString()). Remove(6)
ElseIf (number < 9999) Then
TextBox1.Text = id.Insert(2, (number + 1).ToString()). Remove(6)

End If

it will work untill the no goes dc9999
all the best
Mar 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
2778
by: csomberg | last post by:
SQL 2000 I thought I would throw this out there for some feedback from others. I'd like to know if you feel using MS auto-increment field is a good solution these days or should one grow their own ? Thanks, Me.
13
1648
by: puzzlecracker | last post by:
If you run this program, it will give very unexpected results. Can anyone explain the nature of this anamaly? (also what is the function call to execute 'pause'); #include<stdio.h> //void pause(){ unsigned long i=0; while(i++<10000000); } int main(){ float i;
0
6091
by: Anders W. Pedersen | last post by:
Hi there! I'm working on a medium-sized .NET web application written in c#. We are using Visual Studio 2003 for development and Visual Source Safe as our code repository. Occasionally, we do a build and a deployment to our production server using a batch script which extracts the latest version of our code from VSS, compiles it and copies...
5
5105
by: vul | last post by:
In VB6 there is Auto Increment check box in Project Properties, which allow you have a new version every time you compile the project. Is there any easy way to have this feature in VB 2005? Some of my blocks of code check and compare versions of EXE and DLLs located on the local workstation and the server. So it's very important for me to...
8
6549
by: Candace | last post by:
I am using the following code to pick off each digit of a number, from right to left. The number I am working with is 84357. So for the first iteration it should return the number 7 and for the second iteration it should return the number 5, and so on. But for some reason on the first iteration returns the expected results. Each subsequent...
3
6212
by: crazy123 | last post by:
Please guide me as how do can we create a aut generated number... I have created a database. I am giving each name in the database entry a unique ID I want the Unique ID to be auto generated when I want to add an entry in the database in an increment fashion Do let me know ur views and the code that works...I m in urgent need of...
0
1115
by: vidhyapriya | last post by:
how to increment 4 digit number automatically in vb.net windows appln for example: dc0001-----this is first userid next time i click new button the user id automatically increased to dc0002 likewise i need the format format 0001...if user id 99 the format should be 0099...
3
2792
by: nfrjob | last post by:
Hi there, I'm an advanced beginner, so please bear with me... I have a simple table that has four fields in it: Zone (which will store a three letter code such as ABC), Year (a four digit number field), Number (which is the problem field) and Label (which will be the concatenation of the previous three fields). There will be a variety of...
5
8081
by: David Wright | last post by:
Hello Everyone I would be grateful if someone could help me with the automatic increment of a field on my subform called ‘Test_SrNo’. I am Using Microsoft Office 2000. The auto entry of the incremented number would help to reduce errors and make data entry simpler. The next record in the Test_SrNo field should not have any entry in it until...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.