0

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 by swathys: n/a

6
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by swathys
Featured Replies
  • This is an example with listbox for getting your solution. Hope, it will solve your problem. [CODE] 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 & " " & … Read More

  • Hi, Convert your "CurrentTranxDateTime" to string before manipulation. Thanks, Read More

  • If I read that right then you basically want to put an incremental number after those dates right? like: <DateTime1> [B]1[/B] <DateTime2> [B]2[/B] ... If so then u just need: [CODE] dim CurrentTranxDateTime as date dim UniqueID as string For i As Integer = 1 To 10 'change next line … Read More

  • [QUOTE=swathys;1524767]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 [COLOR="Red"]the number doesnt +1 for each transaction[/COLOR].....any1 have idea to solve this..... eg: 300111 01:45:29 AM 1 300111 01:45:29 AM … Read More

0

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 by sarifah n: n/a

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

Hi,

Convert your "CurrentTranxDateTime" to string before manipulation.

Thanks,

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

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
1

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 by codeorder: n/a

Comments
thank you
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.