hi,

i would like to create an uniqueID where it must add +1 behind the CurrentTranxDateTime for the transaction 1 to 10....I have coded as below but the problem is the number doesnt +1 for each transaction.....any1 have idea to solve this.....
eg: 300111 01:45:29 AM 1
300111 01:45:29 AM 2
300111 01:45:29 AM 3

dim CurrentTranxDateTime as date
dim UniqueID as string
            For i As Integer = 1 To 10
           ' UniqueID = CurrentTranxDateTime & i + 1.ToString()
           UniqueID = CurrentTranxDateTime + i.ToString()
            Next i

Recommended Answers

All 6 Replies

if you use mssql server 2005, you can create a column to increment the number.so you can call the value in this column.

[ID] [int]NOT NULL IDENTITY(1,1),

This is an example with listbox for getting your solution. Hope, it will solve your problem.

Dim A As Integer = 0

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        A = A + 1
        If Trim(TextBox1.Text) = Trim(Now) Then
            ListBox1.Items.Add(Now & " " & A)
        Else
            A = 1
            ListBox1.Items.Add(Now & " " & A)
        End If
        TextBox1.Text = Now
    End Sub
commented: thank you +0

Hi,

Convert your "CurrentTranxDateTime" to string before manipulation.

Thanks,

commented: ya thts rite....i hv convert it to string +0

If I read that right then you basically want to put an incremental number after those dates right?
like:
<DateTime1> 1
<DateTime2> 2
...
If so then u just need:

dim CurrentTranxDateTime as date
dim UniqueID as string
            For i As Integer = 1 To 10
           'change next line in your code:
           UniqueID = CurrentTranxDateTime & " " & i
            Next i

hi,

i would like to create an uniqueID where it must add +1 behind the CurrentTranxDateTime for the transaction 1 to 10....I have coded as below but the problem is the number doesnt +1 for each transaction.....any1 have idea to solve this.....
eg: 300111 01:45:29 AM 1
300111 01:45:29 AM 2
300111 01:45:29 AM 3

dim CurrentTranxDateTime as date
dim UniqueID as string
            For i As Integer = 1 To 10
           ' UniqueID = CurrentTranxDateTime & i + 1.ToString()
           UniqueID = CurrentTranxDateTime + i.ToString()
            Next i

It does +1, but since you are running a loop and keep changing "the same" value until the loop ends, the value will always be a 10 at the end of your UniqueID .

This will give you all 10 in the same String.

UniqueID &= CStr(CurrentTranxDateTime) & i.ToString & vbNewLine
commented: thank you +0

thank you so much its really usefull

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.