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

Edited 5 Years Ago by swathys: n/a

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),

Edited 5 Years Ago by sarifah n: n/a

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
Comments
thank you

Hi,

Convert your "CurrentTranxDateTime" to string before manipulation.

Thanks,

Comments
ya thts rite....i hv convert it to string

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

Edited 5 Years Ago by codeorder: n/a

Comments
thank you
This question has already been answered. Start a new discussion instead.