Ungültiger Parametername me.hide

  • VB.NET

Es gibt 11 Antworten in diesem Thema. Der letzte Beitrag () ist von RodFromGermany.

    Ungültiger Parametername me.hide

    Hallo !

    Warum erhalte ich eine fehlermeldung ?

    VB.NET-Quellcode

    1. bmp.Save(SpeicherPfad & "\" & namenlabel.Text & "-" & i & ".jpg")
    2. PictureBox1.Image.Dispose()
    3. File.Delete(ListBox1.Items(0))
    4. ListBox1.Items.Remove(ListBox1.Items(0))
    5. Try
    6. PictureBox1.Image = Image.FromFile(ListBox1.Items(0))
    7. Catch ex As Exception
    8. PictureBox1.Image.Dispose()
    9. Me.Hide()
    10. End Try
    In welcher / was für einer Klasse und in welcher Prozedur steht dieser Code?
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Button 1_click:

    VB.NET-Quellcode

    1. If ComboBox1.Text = "" Then
    2. MsgBox("Benutzer wählen!", MsgBoxStyle.Exclamation)
    3. Exit Sub
    4. End If
    5. Dim SpeicherPfad As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Benutzer\" & namenlabel.Text)
    6. Dim i As Integer = 1
    7. Dim bmp As New Bitmap(PictureBox1.Image)
    8. Dim g As Graphics = Graphics.FromImage(bmp)
    9. If zusatztb.Text = "" Then
    10. g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - (bmp.VerticalResolution - 50), 200, 50))
    11. g.FillRectangle(Brushes.Black, New Rectangle(bmp.Width - 190, 0, bmp.Width, 25))
    12. g.DrawString(DateTime.Now, New Font("Arial", 14), Brushes.White, New Point(bmp.Width - 190, 0))
    13. g.DrawString(namenlabel.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - (bmp.VerticalResolution - 60)))
    14. Else
    15. g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - (bmp.VerticalResolution - 50), 300, 50))
    16. g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - (bmp.VerticalResolution), 200, 50))
    17. g.FillRectangle(Brushes.Black, New Rectangle(bmp.Width - 190, 0, bmp.Width, 25))
    18. g.DrawString(zusatztb.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - (bmp.VerticalResolution - 60)))
    19. g.DrawString(DateTime.Now, New Font("Arial", 14), Brushes.White, New Point(bmp.Width - 190, 0))
    20. g.DrawString(namenlabel.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - bmp.VerticalResolution + 10))
    21. End If
    22. Do While File.Exists(SpeicherPfad & "\" & namenlabel.Text & "-" & i & ".jpg")
    23. i += 1
    24. Loop
    25. bmp.Save(SpeicherPfad & "\" & namenlabel.Text & "-" & i & ".jpg")
    26. PictureBox1.Image.Dispose()
    27. File.Delete(ListBox1.Items(0))
    28. ListBox1.Items.Remove(ListBox1.Items(0))
    29. Try
    30. PictureBox1.Image = Image.FromFile(ListBox1.Items(0))
    31. Catch ex As Exception
    32. MsgBox("Keine weiteren Bilder vorhanden! Bitte Kamera abschließen", MsgBoxStyle.Information)
    33. End Try
    Ja und?
    Was willst Du uns mit diesem Code sagen?
    Ich hatte die Vermutung, dass Du diesen Code in einer nicht von Form abgeleiteten Klasse aufrufst.
    Das ist wohl nicht der Fall.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Hier mal der gesamte source - ich find einfach den fehler nicht - wäre sehrrrrrrrr dankbar wenn mir jemand hilt - alles ist fertig und nun hab ich nen wurm drinne -.-

    VB.NET-Quellcode

    1. Imports System.IO
    2. Public Class Form1
    3. Dim PfadAufDemDevice = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Bilderpfad.txt")
    4. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    5. Dim LW As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Laufwerkbuchstabe.txt")
    6. If Directory.Exists(LW & ":\") Then
    7. PictureBox1.Image = PictureBox1.ErrorImage
    8. ListBox1.Items.Clear()
    9. Me.Show()
    10. Timer1.Stop()
    11. timer2.start()
    12. For Each item In Directory.GetFiles(LW & ":\" & PfadAufDemDevice)
    13. ListBox1.Items.Add(item)
    14. Next
    15. Try
    16. PictureBox1.Image = Image.FromFile(ListBox1.Items(0))
    17. Catch ex As Exception
    18. MsgBox("Keine Bilder gefunden! Kamera abschließen!", MsgBoxStyle.Exclamation)
    19. End Try
    20. Else
    21. Me.Hide()
    22. End If
    23. End Sub
    24. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    25. Timer1.Start()
    26. For Each items In New System.IO.DirectoryInfo(Application.StartupPath & "\resources\Benutzer").GetFiles()
    27. ComboBox1.Items.Add(items)
    28. Next
    29. End Sub
    30. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    31. End Sub
    32. Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    33. namenlabel.Text = ComboBox1.Text
    34. End Sub
    35. Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    36. If ComboBox1.Text = "" Then
    37. MsgBox("Benutzer wählen!", MsgBoxStyle.Exclamation)
    38. Exit Sub
    39. End If
    40. Dim SpeicherPfad As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Benutzer\" & namenlabel.Text)
    41. Dim i As Integer = 1
    42. Dim bmp As New Bitmap(PictureBox1.Image)
    43. Dim g As Graphics = Graphics.FromImage(bmp)
    44. If zusatztb.Text = "" Then
    45. g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - (bmp.VerticalResolution - 50), 200, 50))
    46. g.FillRectangle(Brushes.Black, New Rectangle(bmp.Width - 190, 0, bmp.Width, 25))
    47. g.DrawString(DateTime.Now, New Font("Arial", 14), Brushes.White, New Point(bmp.Width - 190, 0))
    48. g.DrawString(namenlabel.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - (bmp.VerticalResolution - 60)))
    49. Else
    50. g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - (bmp.VerticalResolution - 50), 300, 50))
    51. g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - (bmp.VerticalResolution), 200, 50))
    52. g.FillRectangle(Brushes.Black, New Rectangle(bmp.Width - 190, 0, bmp.Width, 25))
    53. g.DrawString(zusatztb.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - (bmp.VerticalResolution - 60)))
    54. g.DrawString(DateTime.Now, New Font("Arial", 14), Brushes.White, New Point(bmp.Width - 190, 0))
    55. g.DrawString(namenlabel.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - bmp.VerticalResolution + 10))
    56. End If
    57. Do While File.Exists(SpeicherPfad & "\" & namenlabel.Text & "-" & i & ".jpg")
    58. i += 1
    59. Loop
    60. bmp.Save(SpeicherPfad & "\" & namenlabel.Text & "-" & i & ".jpg")
    61. PictureBox1.Image.Dispose()
    62. Dim LW As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Laufwerkbuchstabe.txt")
    63. File.Delete(ListBox1.Items(0))
    64. ListBox1.Items.Remove(ListBox1.Items(0))
    65. Try
    66. PictureBox1.Image = Image.FromFile(ListBox1.Items(0))
    67. Catch ex As Exception
    68. !! FEHLER LIEGT HIER !!
    69. End Try
    70. End Sub
    71. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    72. Dim LW As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Laufwerkbuchstabe.txt")
    73. If Directory.Exists(LW & ":\") Then
    74. Me.Show()
    75. Else
    76. Me.Hide()
    77. Timer2.Stop()
    78. Timer1.Start()
    79. End If
    80. End Sub
    81. Private Sub AnlegenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnlegenToolStripMenuItem.Click
    82. Dim LW As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Laufwerkbuchstabe.txt")
    83. Dim Name As String = InputBox("Name: ")
    84. Dim Pfad As String
    85. If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
    86. Pfad = FolderBrowserDialog1.SelectedPath
    87. End If
    88. My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\resources\Benutzer\" & Name, Pfad, False)
    89. ComboBox1.Items.Clear()
    90. For Each items In New System.IO.DirectoryInfo(Application.StartupPath & "\resources\Benutzer").GetFiles()
    91. ComboBox1.Items.Add(items)
    92. Next
    93. End Sub
    94. Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
    95. e.Cancel = True
    96. End Sub
    97. Private Sub BeendenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeendenToolStripMenuItem.Click
    98. Me.Close()
    99. End Sub
    100. End Class
    Nimm mal das:
    Spoiler anzeigen

    VB.NET-Quellcode

    1. Imports System.IO
    2. Public Class Form1
    3. Dim PfadAufDemDevice As String '= My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Bilderpfad.txt")
    4. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    5. Dim LW As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Laufwerkbuchstabe.txt")
    6. If Directory.Exists(LW & ":\") Then
    7. PictureBox1.Image = PictureBox1.ErrorImage
    8. ListBox1.Items.Clear()
    9. Me.Show()
    10. Timer1.Stop()
    11. timer2.start()
    12. For Each item In Directory.GetFiles(LW & ":\" & PfadAufDemDevice)
    13. ListBox1.Items.Add(item)
    14. Next
    15. Try
    16. PictureBox1.Image = Image.FromFile(ListBox1.Items(0).ToString)
    17. Catch ex As Exception
    18. MsgBox("Keine Bilder gefunden! Kamera abschließen!", MsgBoxStyle.Exclamation)
    19. End Try
    20. Else
    21. Me.Hide()
    22. End If
    23. End Sub
    24. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    25. PfadAufDemDevice = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Bilderpfad.txt")
    26. Timer1.Start()
    27. For Each items In New System.IO.DirectoryInfo(Application.StartupPath & "\resources\Benutzer").GetFiles()
    28. ComboBox1.Items.Add(items)
    29. Next
    30. End Sub
    31. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    32. End Sub
    33. Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    34. namenlabel.Text = ComboBox1.Text
    35. End Sub
    36. Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    37. If ComboBox1.Text = "" Then
    38. MsgBox("Benutzer wählen!", MsgBoxStyle.Exclamation)
    39. Exit Sub
    40. End If
    41. Dim SpeicherPfad As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Benutzer\" & namenlabel.Text)
    42. Dim i As Integer = 1
    43. Dim bmp As New Bitmap(PictureBox1.Image)
    44. Dim g As Graphics = Graphics.FromImage(bmp)
    45. If zusatztb.Text = "" Then
    46. g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - CInt(bmp.VerticalResolution - 50), 200, 50))
    47. g.FillRectangle(Brushes.Black, New Rectangle(bmp.Width - 190, 0, bmp.Width, 25))
    48. g.DrawString(DateTime.Now.ToShortDateString, New Font("Arial", 14), Brushes.White, New Point(bmp.Width - 190, 0))
    49. g.DrawString(namenlabel.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - CInt(bmp.VerticalResolution - 60)))
    50. Else
    51. g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - CInt(bmp.VerticalResolution - 50), 300, 50))
    52. g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - CInt(bmp.VerticalResolution), 200, 50))
    53. g.FillRectangle(Brushes.Black, New Rectangle(bmp.Width - 190, 0, bmp.Width, 25))
    54. g.DrawString(zusatztb.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - CInt(bmp.VerticalResolution - 60)))
    55. g.DrawString(DateTime.Now.ToShortDateString, New Font("Arial", 14), Brushes.White, New Point(bmp.Width - 190, 0))
    56. g.DrawString(namenlabel.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - CInt(bmp.VerticalResolution) + 10))
    57. End If
    58. Do While File.Exists(SpeicherPfad & "\" & namenlabel.Text & "-" & i & ".jpg")
    59. i += 1
    60. Loop
    61. bmp.Save(SpeicherPfad & "\" & namenlabel.Text & "-" & i & ".jpg")
    62. PictureBox1.Image.Dispose()
    63. Dim LW As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Laufwerkbuchstabe.txt")
    64. File.Delete(ListBox1.Items(0).ToString)
    65. ListBox1.Items.Remove(ListBox1.Items(0))
    66. Try
    67. PictureBox1.Image = Image.FromFile(ListBox1.Items(0).ToString)
    68. Catch ex As Exception
    69. '!! FEHLER LIEGT HIER !!
    70. End Try
    71. End Sub
    72. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    73. Dim LW As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Laufwerkbuchstabe.txt")
    74. If Directory.Exists(LW & ":\") Then
    75. Me.Show()
    76. Else
    77. Me.Hide()
    78. Timer2.Stop()
    79. Timer1.Start()
    80. End If
    81. End Sub
    82. Private Sub AnlegenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnlegenToolStripMenuItem.Click
    83. Dim LW As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Laufwerkbuchstabe.txt")
    84. Dim Name As String = InputBox("Name: ")
    85. Dim Pfad As String
    86. If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
    87. Pfad = FolderBrowserDialog1.SelectedPath
    88. End If
    89. My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\resources\Benutzer\" & Name, Pfad, False)
    90. ComboBox1.Items.Clear()
    91. For Each items In New System.IO.DirectoryInfo(Application.StartupPath & "\resources\Benutzer").GetFiles()
    92. ComboBox1.Items.Add(items)
    93. Next
    94. End Sub
    95. Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
    96. e.Cancel = True
    97. End Sub
    98. Private Sub BeendenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeendenToolStripMenuItem.Click
    99. Me.Close()
    100. End Sub
    101. End Class
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Ich hab den Inhalt nicht weiter verfolgt.
    Mach vllt. eine For Each-Schleife über alle ListBox-Items, da bist Du halt fertig, wenn alle abgearbeitet sind, da brauchst Du kein Try / Catch.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!

    kikipetro schrieb:

    kommt die selbe fehlermeldung

    Was muss ich tun, um den Fehler reproduzieren zu können?
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!