Anonymous
Anonymous asked in 電腦與網際網路程式設計 · 1 decade ago

流水號程式

下列程式要加入些什麼後三碼的會因為系統的年改變而變回001?

Dim a = 0

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim ss = ""

a += 1

ss += IIf(a / 10 > 1, "", "0")

ss += IIf(a / 100 > 1, "", "0")

ss += LTrim(Str(a))

TextBox1.Text = CStr(Year(Now)) + IIf(Month(Now) > 9, "", "0") + CStr(Month(Now)) + ss

End Sub

End Class

1 Answer

Rating
  • 阿戊
    Lv 7
    1 decade ago
    Favorite Answer

    Public Class Form1

    Dim a = 0

    Dim y = 0

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim ss = ""

    If y <> Year(Now) Then a = 0

    a += 1

    If y = 0 Then y = Year(Now)

    ss += IIf(a / 10 > 1, "", "0")

    ss += IIf(a / 100 > 1, "", "0")

    ss += LTrim(Str(a))

    TextBox1.Text = CStr(Year(Now)) + IIf(Month(Now) > 9, "", "0") + CStr(Month(Now)) + ss

    End Sub

    End Class

Still have questions? Get your answers by asking now.