For i As Integer = 0 To CInt(txtloop.Text) - 1 Step +1
cmd.Connection = conn
cmd.CommandText = "INSERT INTO [...] ([Code]) VALUES ('" & CInt(txtCode.Text) + i & "')
cmd.ExecuteNonQuery()
next
ค่าสมมุติครับ : E-845 ถ้า txtloop.text = 2
= E-845
= E-846
Tag : .NET, Ms SQL Server 2008, VBScript, Crystal Report, Win (Windows App), VB.NET
For i As Integer = 0 To CInt(txtloop.Text) - 1 Step +1
Dim s() As String = txtCode.Text.Split("-")
cmd.Connection = conn
cmd.CommandText = "INSERT INTO [...] ([Code]) VALUES ('" & s(0) & "-" & (CInt(s(1)) + i) & "')
cmd.ExecuteNonQuery()
next
'ไม่รู้ว่าใช้ได้ป่าว ลองดูนะครับ
Date :
2018-02-08 11:53:44
By :
IT_man
No. 3
Guest
Code (VB.NET)
Dim s() As String = txtCode.Text.Split("-")
dim Sint As Integer = Cint(s(1))
For i As Integer = 0 To CInt(txtloop.Text) - 1 Step +1
Sint = Sint + i
cmd.Connection = conn
cmd.CommandText = "INSERT INTO [...] ([Code]) VALUES ('" & s(0) & "-" & (Sint) & "')
cmd.ExecuteNonQuery()
next
Dim s() As String = txtCode.Text.Split("-")
Dim Sint As Integer = CInt(s(1))
For i As Integer = 0 To CInt(txtloop.Text) - 2 Step +1
If i = 0 Then
cmd.Connection = conn
cmd.CommandText = "INSERT INTO [...] ([Code]) VALUES ('" & txtCode.Text & "')
cmd.ExecuteNonQuery()
End If
Sint = Sint + 1
cmd.Connection = conn
cmd.CommandText = "INSERT INTO [...] ([Code]) VALUES ('" & s(0) & "-" & (Sint) & "')"
cmd.ExecuteNonQuery()
Next