Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.Odbc
- Public Class Form9
- Dim koneksi As OdbcConnection
- Dim stringKoneksi As String = "DSN=localhost"
- Dim stringSQL As String
- Private Sub Form9_Load(sender As Object, e As System.EventArgs) Handles Me.Load
- koneksi = New OdbcConnection(stringKoneksi)
- stringSQL = "SELECT * FROM tanggal ORDER BY idtanggal desc"
- Dim perintah As New OdbcCommand(stringSQL, koneksi)
- Try
- koneksi.Open()
- Dim baca As OdbcDataReader = perintah.ExecuteReader
- baca.Read()
- If Not baca.HasRows Then
- TextBox1.Text = "TG" + "0001"
- Else
- TextBox1.Text = Val(Microsoft.VisualBasic.Mid(baca.Item("idtanggal").ToString, 4, 3)) + 1
- If Len(TextBox1.Text) = 1 Then
- TextBox1.Text = "TG000" & TextBox1.Text & ""
- ElseIf Len(TextBox1.Text) = 2 Then
- TextBox1.Text = "TG00" & TextBox1.Text & ""
- ElseIf Len(TextBox1.Text) = 3 Then
- TextBox1.Text = "TG0" & TextBox1.Text & ""
- End If
- End If
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- End Try
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement