Liebe VB-Paradise Users,
Ich hab mal wieder eine kleines Problem.
Ich möchte von einer TextBox verschiedene Events auswerten. Wenn ich jeweils nur einen Event auswerte funktioniert der Code einwandfrei
Ich möchte wenn die Textbox angeklickt wird (Me.Activated) den bestehenden Wert im Excel speichern. (Funktioniert auch)
Nun möchte ich wenn der Wert geädert wird dies in einer neuen Zeile im Excel eintragen. Mit diesem Event will es aber nicht klappen.
Was ist an
If tb_value1.TextChanged Then
falsch?
Vielen Dank für Eure Hilfe
Ich hab mal wieder eine kleines Problem.
Ich möchte von einer TextBox verschiedene Events auswerten. Wenn ich jeweils nur einen Event auswerte funktioniert der Code einwandfrei
Ich möchte wenn die Textbox angeklickt wird (Me.Activated) den bestehenden Wert im Excel speichern. (Funktioniert auch)
Nun möchte ich wenn der Wert geädert wird dies in einer neuen Zeile im Excel eintragen. Mit diesem Event will es aber nicht klappen.
Was ist an
If tb_value1.TextChanged Then
falsch?
Vielen Dank für Eure Hilfe
VB.NET-Quellcode
- Private Sub TextBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Activated
- oExcel = CreateObject("Excel.Application")
- oExcel.Visible = False
- oBook = oExcel.Workbooks.add
- oSheet = oBook.Worksheets(1)
- oSheet.Activate()
- 'Start a new workbook in Excel
- 'Set oExcel = CreateObject("Excel.Application")
- 'Set oBook = oExcel.Workbooks.Add
- 'Add data to cells of the first worksheet in the new workbook
- 'Set oSheet = oBook.Worksheets(1)
- oSheet.Range("A1").Value = "Wert vorher"
- oSheet.Range("B1").Value = "Wert nacher"
- oSheet.Range("A1:B1").Font.Bold = True
- oSheet.Range("A2").Value = tb_value1.Text
- 'oSheet.Range("B2").Value = "John"
- 'Save the Workbook and Quit Excel
- oExcel.DisplayAlerts = False
- oBook.SaveAs("C:\Documents and Settings\xxx\Desktop\TEST Programme")
- oExcel.DisplayAlerts = True
- oExcel.Quit()
- If tb_value1.TextChanged Then
- oExcel = CreateObject("Excel.Application")
- oExcel.Visible = False
- oBook = oExcel.Workbooks.add
- oSheet = oBook.Worksheets(1)
- oSheet.Activate()
- 'Start a new workbook in Excel
- 'Set oExcel = CreateObject("Excel.Application")
- 'Set oBook = oExcel.Workbooks.Add
- 'Add data to cells of the first worksheet in the new workbook
- 'Set oSheet = oBook.Worksheets(1)
- oSheet.Range("A1").Value = "Wert vorher"
- oSheet.Range("B1").Value = "Wert nacher"
- oSheet.Range("A1:B1").Font.Bold = True
- 'oSheet.Range("A2").Value = tb_value1.Text
- oSheet.Range("B2").Value = tb_value1.Text
- 'My.Settings.Save()
- 'Save the Workbook and Quit Excel
- oExcel.DisplayAlerts = False
- oBook.SaveAs("C:\Documents and Settings\xxx\Desktop\TEST Programme")
- oExcel.DisplayAlerts = True
- oExcel.Quit()
- End If
- End Sub