Er der nogen der kan finde fejlen?
Hej.Jeg har arbejdet med dette program, og kan ikke få det til at køre. er de nogen der kan gennemskue hvor fejlen ligger?
På forhånd tak for hjælpen.
LadyHawk :o)
___________________________________________________________
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents ListBox2 As System.Windows.Forms.ListBox
Friend WithEvents ListBox3 As System.Windows.Forms.ListBox
Friend WithEvents ListBox4 As System.Windows.Forms.ListBox
Friend WithEvents VScrollBar1 As System.Windows.Forms.VScrollBar
Friend WithEvents VScrollBar2 As System.Windows.Forms.VScrollBar
Friend WithEvents VScrollBar3 As System.Windows.Forms.VScrollBar
Friend WithEvents VScrollBar4 As System.Windows.Forms.VScrollBar
Friend WithEvents VScrollBar5 As System.Windows.Forms.VScrollBar
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents nrpost As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.DataGrid1 = New System.Windows.Forms.DataGrid()
Me.ListBox1 = New System.Windows.Forms.ListBox()
Me.ListBox2 = New System.Windows.Forms.ListBox()
Me.ListBox3 = New System.Windows.Forms.ListBox()
Me.ListBox4 = New System.Windows.Forms.ListBox()
Me.VScrollBar1 = New System.Windows.Forms.VScrollBar()
Me.VScrollBar2 = New System.Windows.Forms.VScrollBar()
Me.VScrollBar3 = New System.Windows.Forms.VScrollBar()
Me.VScrollBar4 = New System.Windows.Forms.VScrollBar()
Me.VScrollBar5 = New System.Windows.Forms.VScrollBar()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.TextBox3 = New System.Windows.Forms.TextBox()
Me.TextBox4 = New System.Windows.Forms.TextBox()
Me.TextBox5 = New System.Windows.Forms.TextBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.nrpost = New System.Windows.Forms.TextBox()
Me.Button2 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.Button4 = New System.Windows.Forms.Button()
Me.Label6 = New System.Windows.Forms.Label()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(64, 344)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(688, 192)
Me.DataGrid1.TabIndex = 0
'
'ListBox1
'
Me.ListBox1.Location = New System.Drawing.Point(304, 136)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(104, 134)
Me.ListBox1.TabIndex = 1
'
'ListBox2
'
Me.ListBox2.Location = New System.Drawing.Point(424, 136)
Me.ListBox2.Name = "ListBox2"
Me.ListBox2.Size = New System.Drawing.Size(104, 134)
Me.ListBox2.TabIndex = 2
'
'ListBox3
'
Me.ListBox3.Location = New System.Drawing.Point(544, 136)
Me.ListBox3.Name = "ListBox3"
Me.ListBox3.Size = New System.Drawing.Size(104, 134)
Me.ListBox3.TabIndex = 3
'
'ListBox4
'
Me.ListBox4.Location = New System.Drawing.Point(664, 136)
Me.ListBox4.Name = "ListBox4"
Me.ListBox4.Size = New System.Drawing.Size(96, 134)
Me.ListBox4.TabIndex = 4
'
'VScrollBar1
'
Me.VScrollBar1.Location = New System.Drawing.Point(392, 136)
Me.VScrollBar1.Name = "VScrollBar1"
Me.VScrollBar1.Size = New System.Drawing.Size(17, 136)
Me.VScrollBar1.TabIndex = 5
'
'VScrollBar2
'
Me.VScrollBar2.Location = New System.Drawing.Point(512, 136)
Me.VScrollBar2.Name = "VScrollBar2"
Me.VScrollBar2.Size = New System.Drawing.Size(17, 136)
Me.VScrollBar2.TabIndex = 6
'
'VScrollBar3
'
Me.VScrollBar3.Location = New System.Drawing.Point(632, 136)
Me.VScrollBar3.Name = "VScrollBar3"
Me.VScrollBar3.Size = New System.Drawing.Size(17, 136)
Me.VScrollBar3.TabIndex = 7
'
'VScrollBar4
'
Me.VScrollBar4.Location = New System.Drawing.Point(744, 136)
Me.VScrollBar4.Name = "VScrollBar4"
Me.VScrollBar4.Size = New System.Drawing.Size(17, 136)
Me.VScrollBar4.TabIndex = 8
'
'VScrollBar5
'
Me.VScrollBar5.Location = New System.Drawing.Point(736, 344)
Me.VScrollBar5.Name = "VScrollBar5"
Me.VScrollBar5.Size = New System.Drawing.Size(17, 192)
Me.VScrollBar5.TabIndex = 9
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(24, 120)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 23)
Me.Label1.TabIndex = 10
Me.Label1.Text = "Telefon"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(24, 152)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(48, 23)
Me.Label2.TabIndex = 11
Me.Label2.Text = "Navn"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(24, 184)
Me.Label3.Name = "Label3"
Me.Label3.TabIndex = 12
Me.Label3.Text = "Adresse"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(24, 216)
Me.Label4.Name = "Label4"
Me.Label4.TabIndex = 13
Me.Label4.Text = "PostNr."
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(24, 248)
Me.Label5.Name = "Label5"
Me.Label5.TabIndex = 14
Me.Label5.Text = "By"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(104, 120)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(104, 20)
Me.TextBox1.TabIndex = 15
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(104, 152)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(104, 20)
Me.TextBox2.TabIndex = 16
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(104, 184)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(104, 20)
Me.TextBox3.TabIndex = 17
Me.TextBox3.Text = ""
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(104, 216)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(104, 20)
Me.TextBox4.TabIndex = 18
Me.TextBox4.Text = ""
'
'TextBox5
'
Me.TextBox5.Location = New System.Drawing.Point(104, 248)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(104, 20)
Me.TextBox5.TabIndex = 19
Me.TextBox5.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(160, 304)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 20
Me.Button1.Text = "Find"
'
'nrpost
'
Me.nrpost.AccessibleDescription = ""
Me.nrpost.Location = New System.Drawing.Point(64, 304)
Me.nrpost.Name = "nrpost"
Me.nrpost.Size = New System.Drawing.Size(56, 20)
Me.nrpost.TabIndex = 21
Me.nrpost.Text = ""
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(296, 304)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 22
Me.Button2.Text = "Ret"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(448, 304)
Me.Button3.Name = "Button3"
Me.Button3.TabIndex = 23
Me.Button3.Text = "Slet"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(600, 304)
Me.Button4.Name = "Button4"
Me.Button4.TabIndex = 24
Me.Button4.Text = "Opret Ny"
'
'Label6
'
Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 21.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.Location = New System.Drawing.Point(232, 32)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(304, 40)
Me.Label6.TabIndex = 25
Me.Label6.Text = "Database Eksempel"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(768, 558)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label6, Me.Button4, Me.Button3, Me.Button2, Me.nrpost, Me.Button1, Me.TextBox5, Me.TextBox4, Me.TextBox3, Me.TextBox2, Me.TextBox1, Me.Label5, Me.Label4, Me.Label3, Me.Label2, Me.Label1, Me.VScrollBar5, Me.VScrollBar4, Me.VScrollBar3, Me.VScrollBar2, Me.VScrollBar1, Me.ListBox4, Me.ListBox3, Me.ListBox2, Me.ListBox1, Me.DataGrid1})
Me.Name = "Form1"
Me.Text = "Database Eksempel"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim Venner As New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyCon As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" & Application.StartupPath & "\friends.mdb")
Dim MyAdap As New OleDbDataAdapter("select * from vennetabel", MyCon)
Venner.Reset()
MyAdap.Fill(Venner)
DataGrid1.DataSource = Venner
DataGrid1.SetDataBinding(Venner, Venner.Tables(0).ToStrings)
nrpost.Text = Venner.Tables(0).Rows.Count.ToString
FillLists()
End Sub
Private Sub UpdateLists(ByVal nr As Integer)
ListBox1.SelectedIndex = nr
ListBox3.SelectedIndex = nr
ListBox3.SelectedIndex = nr
ListBox4.SelectedIndex = nr
End Sub
Private Sub FillLists()
Dim MyCon As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" &
Application.StartupPath & "\friends.mdb")
Dim MyAdap As New OleDbDataAdapter("select * from vennetabel", MyCon)
Dim a, i As Integer
a = Venner.Tables(0).Rows.Count - 1
Venner.Clear()
MyAdap.Fill(Venner)
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
ListBox4.Items.Clear()
For i = 0 To a
ListBox1.Items.Add(Venner.Tables(0).Rows.Item("telefon"))
ListBox2.Items.Add(Venner.Tables(0).Rows(i).Item("Navn"))
ListBox3.Items.Add(Venner.Tables(0).Rows.Item("adresse"))
ListBox4.Items.Add(Venner.Tables(0).Rows(i).Item("postby"))
Next
End Sub
Private Sub SletTextBoxe()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.click
Dim MyCon As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" &
Application.StartupPath & "\friends.mdb")
Dim MyAdap As New OleDbDataAdapter("select * from vennetabel", MyCon)
Dim i As Integer
If CInt(nrpost.Text) > Venner.Tables(0).Rows.Count Then
nrpost.Text = Venner.Tables(0).Rows.Count).ToString
End If
i = CInt(nrpost.Text) - 1
Venner.Clear()
MyAdap.Fill(Venner)
TextBox1.Text = Venner.Tables(0).Rows(i).Item("telefon")
TextBox1.Text = Venner.Tables(0).Rows(i).Item("Navn")
TextBox1.Text = Venner.Tables(0).Rows(i).Item("adresse")
TextBox1.Text = Venner.Tables(0).Rows(i).Item("postnr")
TextBox1.Text = Venner.Tables(0).Rows(i).Item("postby")
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim MyCon As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" &
Application.StartupPath & "\friends.mdb")
Dim MyAdap As New OleDbDataAdapter("select * from vennetabel", MyCon)
Dim MySQL As String = "UPDATE vennetabel SET Navn ='" &
TextBox2.Text & "',adresse = '" &
TextBox3.Text & "',postnr = '" &
TextBox4.Text & "',postby & '"
TextBox5.Text & "' where telefon = '" &
TextBox1.Text & "'"
Dim Cmd As New OleDbCommand(MySQL, MyCon)
MyCon.Open()
Cmd.ExecuteNonQuery()
MyCon.Close()
Venner.Clear()
MyAdap.Fill(Venner)
FillLists()
End Sub
Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim MyCon As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" &
Application.StartupPath & "\friends.mdb")
Dim MyAdap As New OleDataAdapter("select * from vennetabel", MyCon)
Dim MySQL As String = "DELETE FROM vennetabel where telefon = '" & TextBox1.Text & "'"
Dim Cmd As New OleDbCommand(MySQL, MyCon)
MyCon.Open()
Cmd.ExecuteNonQuery()
MyCon.Close()
Venner.Clear()
MyAdap.Fill(Venner)
FillLists()
SletTextBoxe()
End Sub
Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim MyCon As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" &
Application.StartupPath & "\friends.mdb")
Dim MySQL As String = "INSERT into vennetabel (telefon, navn, adresse, postnr, postby) values ('" &
TextBox1.Text & "','" &
TextBox2.Text & "','" &
TextBox3.Text & "','" &
TextBox4.Text & "','" &
TextBox5.Text & "')"
Dim Cmd As New OleDbCommand(MySQL, MyCon)
MyCon.Open()
Cmd.ExecuteNonQuery()
MyCon.Close()
Venner.Clear()
MyAdap.Fill(Venner)
FillLists()
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
nrpost.Text = (ListBox1.SelectedIndex + 1).ToString
UpdateLists(ListBox1.SelectedIndex)
Find(ListBox1.SelectedIndex)
End Sub
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
nrpost.Text = (ListBox2.SelectedIndex + 1).ToString
UpdateLists(ListBox2.SelectedIndex)
Find(ListBox2.SelectedIndex)
End Sub
Private Sub ListBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox3.SelectedIndexChanged
nrpost.Text = (ListBox3.SelectedIndex + 1).ToString
UpdateLists(ListBox3.SelectedIndex)
Find(ListBox3.SelectedIndex)
End Sub
Private Sub ListBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox4.SelectedIndexChanged
nrpost.Text = (ListBox4.SelectedIndex + 1).ToString
UpdateLists(ListBox4.SelectedIndex)
Find(ListBox4.SelectedIndex)
End Sub
End Class
