-
Apr 13th, 2025, 02:41 PM
#1
Thread Starter
New Member
[RESOLVED] vb.net published program crashes when drawing into picturebox
Hello,
I'm new here and not a pro, that's why i have to ask the professionals. I made a very simple program for my cousin, which has some textboxes to fill out and
doing some calculations with these inputs. After that you can click a button to draw lines into a picturebox, using the calculated and inserted numbers. In Visual Studio everything is fine,
working without any problems. I published the program, created a setup.exe (had to convert to .net 6.0 first) and let him install it. Now everytime he clicks the button to draw into the picturebox, the program crashes. His operating system is Windows 10 pro. I tried it on a different pc, and it worked without any problem. Maybe someone can help me with this, couldn't find any answer on google or anywhere else.
I think it's a problem with Windows 10 pro, but I'm not sure. Thanks in advance.
Thomas
-
Apr 13th, 2025, 07:05 PM
#2
Re: vb.net published program crashes when drawing into picturebox
It almost definitely isn't a problem with Windows 10 pro.
Did you both use the same input? Could be a .Net Core incompatibility
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 13th, 2025, 10:40 PM
#3
Re: vb.net published program crashes when drawing into picturebox
A crash in an unhandled exception. You need to get the data from that exception because it tells you what the problem is. Windows should provide the information but you can also write code to catch the exception and log the information yourself. Do that and tell us what you find. You should also show us the relevant code. We may know more than you but we still need information to diagnose the issue.
-
Apr 14th, 2025, 06:25 AM
#4
Thread Starter
New Member
Re: vb.net published program crashes when drawing into picturebox
ok, thank You for Your answers. So how can I log whats happening. Just let print into a textfile on the computer in the try catch end try loop? But what do i have to write in that code, so that the problem is written down?
Then release/publish again and let him try, right?
-
Apr 14th, 2025, 07:39 AM
#5
Re: vb.net published program crashes when drawing into picturebox
You may not have to do anything. Usually, if an app crashes, Windows displays a dialogue with a Details button. For .NET apps, that will generally include the exception details. You can just get the user to copy that and provide it to you however is convenient.
As for catching the exception, unless it's something you can reasonable expect to happen, don't catch it explicitly. Add code to handle the UnhandledException event of the application, which you should always be doing anyway. You can then log the exception and shut down cleanly. It's up to you how to log it. You might just display it in a message box and have the user copy it and send it to you. It's completely up to you what's appropriate.
-
Apr 14th, 2025, 11:20 AM
#6
Thread Starter
New Member
Re: vb.net published program crashes when drawing into picturebox
ok, the problem is, there is no Windows dialogue. The program just closes without any error message. i browsed a little bit, and i think this code would do the job, am i right?
```
Code:
Catch ex As Exception
MsgBox(ex.Message)
My.Application.Log.WriteException(ex, TraceEventType.Error, "Exception " & "with argument " & "C:\Log.txt" & ".")
End Try
-
Apr 14th, 2025, 01:31 PM
#7
Re: vb.net published program crashes when drawing into picturebox
That is one way, yes. It might already be logged in the event viewer too, I would suggest checking there first.
-
Apr 15th, 2025, 12:43 AM
#8
Thread Starter
New Member
Re: vb.net published program crashes when drawing into picturebox
ok, the event viewer recorded the crash, that information is inside (some parts in german). But how can i read it. Looks like a dll problem?
System
- Provider
[ Name] Windows Error Reporting
- EventID 1001
[ Qualifiers] 0
Version 0
Level 4
Task 0
Opcode 0
Keywords 0x80000000000000
- TimeCreated
[ SystemTime] 2025-04-15T05:01:22.2090579Z
EventRecordID 282649
Correlation
- Execution
[ ProcessID] 0
[ ThreadID] 0
Channel Application
Computer Sonnenschutzdoktor
Security
- EventData
2245480069158270704
4
APPCRASH
Nicht verfügbar
0
Sonnenschutzdoktor Berechnungsapp.exe
0.0.0.0
670d0000
KERNELBASE.dll
10.0.19041.5678
024a42e4
c000041d
000000000003b699
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER8A31.tmp.WERInternalMetadata.xml
?
\\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_Sonnenschutzdokt_c9ebb2d72221db35458 bc2f664993ba8efa29d1f_588a3b03_d3e4afc5-68f8-42ad-9e85-a9151634de8c
0
23dbe9a5-5192-4210-b5f8-24de1f6bbe5d
268435456
c55d980e4e9de446bf298c39d065f6f0
Last edited by jmcilhinney; Apr 15th, 2025 at 01:57 AM.
-
Apr 15th, 2025, 02:00 AM
#9
Re: vb.net published program crashes when drawing into picturebox
There's no exception data there. How about you do what I suggested - what I suggested you should already be doing because it should be done in every app that supports it - and handle the UnhandledException event of the application?
-
Apr 15th, 2025, 06:53 AM
#10
Thread Starter
New Member
Re: vb.net published program crashes when drawing into picturebox
ok, i try to implement a code to get the exception data from the program itself. I share the information as soon as i get it.
-
Apr 19th, 2025, 03:05 AM
#11
Thread Starter
New Member
Re: vb.net published program crashes when drawing into picturebox
Good Morning, i have an update. Don't know how i did it, but the app doesn't crash anymore. I made several changes to the code. One was to change a variables name from refresh to huibui, maybe the variables name had a conflict with the declaration "refresh". Another change was to make an if loop in every possible critical sub to ask if the operating system iswindows, because i had a lot of green underlines referring to that problem. I also implemented jmcilhinneys exception handling, which led to no result (of the main problem) because the crash is no longer there. Then i outcommented a second variant of painting the lines. I made this first, because i could see the painted lines, but they were not consistent, so when i wanted to print them, they were not there anymore. I also let him install .NET Runtime 6.0 again, although it has been there already. The crash is gone, maybe someone of You can tell me, which of the changes is responsible for that. I tested the program on different computers and it worked fine, only on my cousins PC i got this problems. Now we are standing in front of the next problem. The picturebox is showing a red cross instead of what it should show. I ask for help and show You the whole code of the program, maybe You can tell me why.
Code:
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Printing
Imports System.IO
Imports System.Threading
Public Class Form1
Private huibui As Boolean = False
Private maxwert As Integer = 450
Private Ausladungvar As Double
Private Durchgangvar As Double
Private Montagevar As Double
Private Überhangvar As Double
Private Neigungvar As Double
Private Flächevar As Double
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Location = New Point((My.Computer.Screen.WorkingArea.Width - Me.Width) / 2, (My.Computer.Screen.WorkingArea.Height - Me.Height) / 2)
TextBox1.Text = 0
TextBox14.Text = 0
TextBox3.Text = 0
TextBox5.Text = 0
TextBox8.Text = 0
TextBox1.MaxLength = 9
TextBox14.MaxLength = 9
TextBox3.MaxLength = 9
TextBox5.MaxLength = 9
TextBox8.MaxLength = 9
If OperatingSystem.IsWindows Then
AddHandler PrintDocument1.PrintPage, AddressOf Me.PrintImage
End If
Me.WindowState = FormWindowState.Maximized
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
AddHandler currentDomain.UnhandledException, AddressOf MYExceptionHandler
AddHandler Application.ThreadException, AddressOf MYThreadHandler
End Sub
Private Sub MYExceptionHandler(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
Dim EX As Exception = e.ExceptionObject
Console.WriteLine(EX.StackTrace)
MessageBox.Show(EX.StackTrace)
Dim filepath As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\errorlogfile.txt"
If Not System.IO.File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\errorlogfile.txt") Then
System.IO.File.Create(My.Computer.FileSystem.SpecialDirectories.Desktop & "\errorlogfile.txt").Dispose()
End If
Dim fs As New FileStream(My.Computer.FileSystem.SpecialDirectories.Desktop & "\errorlogfile.txt", FileMode.Append, FileAccess.Write)
Dim s As New StreamWriter(fs, System.Text.Encoding.Default)
s.BaseStream.Seek(0, SeekOrigin.End)
s.Write(EX.StackTrace)
s.Close()
End Sub
Private Sub MYThreadHandler(ByVal sender As Object, ByVal e As Threading.ThreadExceptionEventArgs)
Console.WriteLine(e.Exception.StackTrace)
MessageBox.Show(e.Exception.StackTrace)
Dim filepath As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\errorlogfile.txt"
If Not System.IO.File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\errorlogfile.txt") Then
System.IO.File.Create(My.Computer.FileSystem.SpecialDirectories.Desktop & "\errorlogfile.txt").Dispose()
End If
Dim fs As New FileStream(My.Computer.FileSystem.SpecialDirectories.Desktop & "\errorlogfile.txt", FileMode.Append, FileAccess.Write)
Dim s As New StreamWriter(fs, System.Text.Encoding.Default)
s.BaseStream.Seek(0, SeekOrigin.End)
s.Write(e.Exception.StackTrace)
s.Close()
End Sub
Private Sub Label1_MouseHover(sender As Object, e As EventArgs) Handles Label1.MouseHover
ToolTip1.SetToolTip(Label1, "Für die Berechnung der Ausladung sind Daten in den Feldern Durchgangshöhe, Montagehöhe und Neigung erforderlich")
End Sub
Private Sub Label7_MouseHover(sender As Object, e As EventArgs) Handles Label7.MouseHover
ToolTip2.SetToolTip(Label7, "Für die Berechnung der Durchgangshöhe sind Daten in den Feldern Ausladung, Montagehöhe und Neigung erforderlich")
End Sub
Private Sub Label2_MouseHover(sender As Object, e As EventArgs) Handles Label2.MouseHover
ToolTip3.SetToolTip(Label2, "Für die Berechnung der Montagehöhe sind Daten in den Feldern Ausladung, Durchgangshöhe und Neigung erforderlich")
End Sub
Private Sub Label3_MouseHover(sender As Object, e As EventArgs) Handles Label3.MouseHover
ToolTip4.SetToolTip(Label3, "Für die Berechnung der Neigung sind Daten in den Feldern Ausladung, Durchgangshöhe und Montagehöhe erforderlich")
End Sub
Private Sub Label4_MouseHover(sender As Object, e As EventArgs) Handles Label4.MouseHover
ToolTip5.SetToolTip(Label4, "Wert nur für Berechnung der beschatteten Fläche verwendet")
End Sub
Private Sub Label5_MouseHover(sender As Object, e As EventArgs) Handles Label5.MouseHover
ToolTip6.SetToolTip(Label5, "Für die Berechnung der beschatteten Fläche sind Daten in den Feldern Ausladungund und Markisenbreite erforderlich")
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = "" Then
TextBox7.Text = ""
Exit Sub
ElseIf TextBox1.Text > maxwert Then
MessageBox.Show("Werte über " + maxwert.ToString + " nicht zulässig")
TextBox1.SelectionStart = 0
TextBox1.SelectionLength = TextBox1.Text.Length
ElseIf TextBox1.Text <> "" And TextBox1.Text < maxwert Then
TextBox7.Text = TextBox1.Text
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Asc(e.KeyChar) <> 44 AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Bitte tippen Sie Zahlen ins Feld!")
e.Handled = True
End If
End Sub
Private Sub TextBox14_TextChanged(sender As Object, e As EventArgs) Handles TextBox14.TextChanged
If TextBox14.Text = "" Then
TextBox13.Text = ""
Exit Sub
ElseIf TextBox14.Text > maxwert Then
MessageBox.Show("Werte über " + maxwert.ToString + " nicht zulässig")
TextBox14.SelectionStart = 0
TextBox14.SelectionLength = TextBox14.Text.Length
ElseIf TextBox14.Text <> "" And TextBox14.Text < maxwert Then
TextBox13.Text = TextBox14.Text
End If
End Sub
Private Sub TextBox14_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox14.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Asc(e.KeyChar) <> 44 AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Bitte tippen Sie Zahlen ins Feld!")
e.Handled = True
End If
End Sub
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
If TextBox3.Text = "" Then
TextBox2.Text = ""
Exit Sub
ElseIf TextBox3.Text > maxwert Then
MessageBox.Show("Werte über " + maxwert.ToString + " nicht zulässig")
TextBox3.SelectionStart = 0
TextBox3.SelectionLength = TextBox3.Text.Length
ElseIf TextBox3.Text <> "" And TextBox3.Text < maxwert Then
TextBox2.Text = TextBox3.Text
End If
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Asc(e.KeyChar) <> 44 AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Bitte tippen Sie Zahlen ins Feld!")
e.Handled = True
End If
End Sub
Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
If TextBox5.Text = "" Then
TextBox4.Text = ""
Exit Sub
ElseIf TextBox5.Text > 41 Then
MessageBox.Show("Werte über 40 nicht zulässig")
TextBox5.SelectionStart = 0
TextBox5.SelectionLength = TextBox5.Text.Length
ElseIf TextBox5.Text <> "" And TextBox5.Text < 41 Then
TextBox4.Text = TextBox5.Text
End If
End Sub
Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Asc(e.KeyChar) <> 44 AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Bitte tippen Sie Zahlen ins Feld!")
e.Handled = True
End If
End Sub
Private Sub TextBox8_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox8.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Asc(e.KeyChar) <> 44 AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Bitte tippen Sie Zahlen ins Feld!")
e.Handled = True
End If
End Sub
Private Sub TextBox8_TextChanged(sender As Object, e As EventArgs) Handles TextBox8.TextChanged
If TextBox8.Text = "" Then
TextBox6.Text = ""
Exit Sub
ElseIf TextBox8.Text > 1000 Then
MessageBox.Show("Werte über 1000 nicht zulässig")
TextBox8.SelectionStart = 0
TextBox8.SelectionLength = TextBox8.Text.Length
ElseIf TextBox8.Text <> "" And TextBox8.Text < 1000 Then
TextBox6.Text = TextBox8.Text
End If
End Sub
Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
If OperatingSystem.IsWindows Then
'Dim buffer As Bitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
'Dim g As Graphics = Graphics.FromImage(buffer)
If huibui = True Then
PictureBox1.BackColor = Color.White
Dim p As New Pen(Color.Black, 2)
Dim p1 As New Pen(Color.DeepSkyBlue, 5)
Dim p2 As New Pen(Color.Black, 1)
Dim p3 As New Pen(Color.LightCoral, 3)
Dim p4 As New Pen(Color.LightGreen, 3)
Dim p5 As New Pen(Color.LemonChiffon, 3)
Dim p6 As New Pen(Color.LightPink, 3)
'Koordinatensystem
'y-Achse
e.Graphics.DrawLine(p, 100, 30, 100, 480)
'x-Achse
e.Graphics.DrawLine(p, 100, 480, 550, 480)
'Koordinatenmarkierungsbezeichnung
Dim k As Integer = 0
Dim j As Integer = 0
'für x-Achse
For r = 427 To 27 Step -50
j += 50
e.Graphics.DrawString(j, New Font("Arial", 5, FontStyle.Regular), New SolidBrush(Color.Black), 83, r)
Next r
'für y-Achse
For u = 144 To 544 Step 50
k += 50
e.Graphics.DrawString(k, New Font("Arial", 5, FontStyle.Regular), New SolidBrush(Color.Black), u, 485)
Next u
'Koordinatenmarkierungen
For i = 110 To 550 Step 10
e.Graphics.DrawLine(p2, i, 480, i, 475)
e.Graphics.DrawLine(p2, 100, i - 80, 105, i - 80)
Next i
'Hausmauer
For t = 30 To 450 Step 40
e.Graphics.DrawLine(p, 80, t, 50, t + 20)
Next t
'OUTPUT
'
'
'Markise
e.Graphics.DrawLine(p1, 100, 480 - CInt(TextBox2.Text), 100 + CInt(TextBox15.Text), 480 - CInt(TextBox13.Text))
e.Graphics.DrawString("A", New Font("Arial", 9, FontStyle.Bold), New SolidBrush(Color.Black), 100 + CInt(TextBox15.Text) / 2, 480 - CInt(TextBox2.Text) - 30)
''Abstand von Wand
e.Graphics.DrawLine(p3, 100, 500, 100 + CInt(TextBox15.Text), 500)
'Pfeile und Bezeichnung Wand
e.Graphics.DrawLine(p2, 100, 500, 100, 492)
e.Graphics.DrawLine(p2, 100 + CInt(TextBox15.Text), 500, 100 + CInt(TextBox15.Text), 492)
e.Graphics.DrawLine(p2, 100, 492, 97, 495)
e.Graphics.DrawLine(p2, 100, 492, 103, 495)
e.Graphics.DrawLine(p2, 100 + CInt(TextBox15.Text), 492, 97 + CInt(TextBox15.Text), 495)
e.Graphics.DrawLine(p2, 100 + CInt(TextBox15.Text), 492, 103 + CInt(TextBox15.Text), 495)
e.Graphics.DrawString("B", New Font("Arial", 9, FontStyle.Bold), New SolidBrush(Color.Black), 100 + CInt(TextBox15.Text) / 2, 505)
'Montagehöhe
e.Graphics.DrawLine(p4, 40, 480 - CInt(TextBox2.Text), 40, 480)
'Pfeile und Bezeichnung Montagehöhe
e.Graphics.DrawLine(p2, 40, 480, 48, 480)
e.Graphics.DrawLine(p2, 40, 480 - CInt(TextBox2.Text), 48, 480 - CInt(TextBox2.Text))
e.Graphics.DrawLine(p2, 48, 480, 45, 483)
e.Graphics.DrawLine(p2, 48, 480, 45, 477)
e.Graphics.DrawLine(p2, 48, 480 - CInt(TextBox2.Text), 45, 483 - CInt(TextBox2.Text))
e.Graphics.DrawLine(p2, 48, 480 - CInt(TextBox2.Text), 45, 477 - CInt(TextBox2.Text))
e.Graphics.DrawString("M", New Font("Arial", 9, FontStyle.Bold), New SolidBrush(Color.Black), 20, 480 - CInt(TextBox2.Text) / 2)
'Durchgangshöhe
e.Graphics.DrawLine(p5, 120 + CInt(TextBox15.Text), 480, 120 + CInt(TextBox15.Text), 480 - CInt(TextBox13.Text))
'Pfeile und Bezeichnung Durchgangshöhe
e.Graphics.DrawLine(p2, 120 + CInt(TextBox15.Text), 480, 112 + CInt(TextBox15.Text), 480)
e.Graphics.DrawLine(p2, 120 + CInt(TextBox15.Text), 480 - CInt(TextBox13.Text), 112 + CInt(TextBox15.Text), 480 - CInt(TextBox13.Text))
e.Graphics.DrawLine(p2, 112 + CInt(TextBox15.Text), 480, 115 + CInt(TextBox15.Text), 477)
e.Graphics.DrawLine(p2, 112 + CInt(TextBox15.Text), 480, 115 + CInt(TextBox15.Text), 483)
e.Graphics.DrawLine(p2, 112 + CInt(TextBox15.Text), 480 - CInt(TextBox13.Text), 115 + CInt(TextBox15.Text), 477 - CInt(TextBox13.Text))
e.Graphics.DrawLine(p2, 112 + CInt(TextBox15.Text), 480 - CInt(TextBox13.Text), 115 + CInt(TextBox15.Text), 483 - CInt(TextBox13.Text))
e.Graphics.DrawString("D", New Font("Arial", 9, FontStyle.Bold), New SolidBrush(Color.Black), 100 + CInt(TextBox15.Text) + 30, 480 - CInt(TextBox13.Text) / 2)
'Neigung
e.Graphics.DrawPie(p6, New Rectangle(55, 480 - TextBox2.Text - 40, 100, 100), CSng(90), CSng(TextBox4.Text) - 90)
e.Graphics.DrawString("90-N", New Font("Arial", 9, FontStyle.Bold), New SolidBrush(Color.Black), 105, 480 - CInt(TextBox2.Text) + 35)
'Speichern in Bitmap für Druck
'PictureBox1.Image = buffer
Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(PictureBox1.Width, PictureBox1.Height)
PictureBox1.DrawToBitmap(bmp, PictureBox1.ClientRectangle)
PictureBox1.Image = bmp
End If
End If
huibui = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox7.Text <> "" And TextBox13.Text <> "" And TextBox2.Text <> "" And TextBox15.Text <> "" Then
huibui = True
PictureBox1.Image = Nothing
PictureBox1.Refresh()
Else
MessageBox.Show("Zu wenige oder keine neuen Daten!!")
End If
End Sub
Private Sub TextBox7_TextChanged(sender As Object, e As EventArgs) Handles TextBox7.TextChanged
If TextBox1.Text <> "" And TextBox8.Text <> "" Then
Flächevar = (TextBox1.Text * TextBox8.Text) / 10000
TextBox9.Text = Math.Round(Flächevar, 3)
End If
If TextBox7.Text = "" Or TextBox2.Text = "" Or TextBox13.Text = "" Or TextBox7.Text = "0" Or TextBox2.Text = "0" Or TextBox13.Text = "0" Then
Exit Sub
Else
If TextBox7.Text <> "" And TextBox2.Text <> "" And TextBox13.Text <> "" Then
Überhangvar = Math.Sqrt(TextBox7.Text * TextBox7.Text - (TextBox2.Text - TextBox13.Text) * (TextBox2.Text - TextBox13.Text))
TextBox15.Text = Math.Round(Überhangvar, 2)
End If
End If
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
If TextBox7.Text = "" Or TextBox2.Text = "" Or TextBox13.Text = "" Or TextBox7.Text = "0" Or TextBox2.Text = "0" Or TextBox13.Text = "0" Then
Exit Sub
Else
If TextBox7.Text <> "" And TextBox2.Text <> "" And TextBox13.Text <> "" Then
Flächevar = Math.Sqrt(TextBox7.Text * TextBox7.Text - (TextBox2.Text - TextBox13.Text) * (TextBox2.Text - TextBox13.Text))
TextBox15.Text = Math.Round(Flächevar, 2)
End If
End If
End Sub
Private Sub TextBox13_TextChanged(sender As Object, e As EventArgs) Handles TextBox13.TextChanged
If TextBox7.Text = "" Or TextBox2.Text = "" Or TextBox13.Text = "" Or TextBox7.Text = "0" Or TextBox2.Text = "0" Or TextBox13.Text = "0" Then
Exit Sub
Else
If TextBox7.Text <> "" And TextBox2.Text <> "" And TextBox13.Text <> "" Then
Flächevar = Math.Sqrt(TextBox7.Text * TextBox7.Text - (TextBox2.Text - TextBox13.Text) * (TextBox2.Text - TextBox13.Text))
TextBox15.Text = Math.Round(Flächevar, 2)
End If
End If
End Sub
Private Sub TextBox6_TextChanged(sender As Object, e As EventArgs) Handles TextBox6.TextChanged
If TextBox1.Text And TextBox8.Text <> "" Then
Flächevar = (TextBox1.Text * TextBox8.Text) / 10000
TextBox9.Text = Math.Round(Flächevar, 3)
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If TextBox13.Text <> "" And TextBox2.Text <> "" And TextBox4.Text <> "" Then
If TextBox13.Text > 0 And TextBox2.Text > 0 And TextBox4.Text > 0 Then
Ausladungvar = (TextBox2.Text - TextBox13.Text) / Math.Sin(TextBox4.Text * Math.PI / 180)
TextBox7.Text = Math.Round(Ausladungvar, 2)
End If
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If TextBox7.Text <> "" And TextBox2.Text <> "" And TextBox4.Text <> "" Then
If TextBox7.Text > 0 And TextBox2.Text > 0 And TextBox4.Text > 0 Then
Durchgangvar = TextBox2.Text - Math.Sin(TextBox4.Text * Math.PI / 180) * TextBox7.Text
TextBox13.Text = Math.Round(Durchgangvar, 2)
End If
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
If TextBox7.Text <> "" And TextBox13.Text <> "" And TextBox4.Text <> "" Then
If TextBox7.Text > 0 And TextBox13.Text > 0 And TextBox4.Text > 0 Then
Montagevar = TextBox13.Text + Math.Sin(TextBox4.Text * Math.PI / 180) * TextBox7.Text
TextBox2.Text = Math.Round(Montagevar, 2)
End If
End If
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
If TextBox2.Text <> "" And TextBox13.Text <> "" And TextBox7.Text <> "" Then
If TextBox7.Text > 0 And TextBox13.Text > 0 And TextBox2.Text > 0 Then
Neigungvar = (Math.Asin((TextBox2.Text - TextBox13.Text) / TextBox7.Text)) * 180 / Math.PI
TextBox4.Text = Math.Round(Neigungvar, 2)
End If
End If
End Sub
Private Sub TextBox1_Click(sender As Object, e As EventArgs) Handles TextBox1.Click
TextBox1.SelectionStart = 0
TextBox1.SelectionLength = TextBox1.Text.Length
End Sub
Private Sub TextBox14_Click(sender As Object, e As EventArgs) Handles TextBox14.Click
TextBox14.SelectionStart = 0
TextBox14.SelectionLength = TextBox14.Text.Length
End Sub
Private Sub TextBox3_Click(sender As Object, e As EventArgs) Handles TextBox3.Click
TextBox3.SelectionStart = 0
TextBox3.SelectionLength = TextBox3.Text.Length
End Sub
Private Sub TextBox5_Click(sender As Object, e As EventArgs) Handles TextBox5.Click
TextBox5.SelectionStart = 0
TextBox5.SelectionLength = TextBox5.Text.Length
End Sub
Private Sub TextBox8_Click(sender As Object, e As EventArgs) Handles TextBox8.Click
TextBox8.SelectionStart = 0
TextBox8.SelectionLength = TextBox8.Text.Length
End Sub
Private Sub PrintImage(ByVal sender As Object, ByVal ppea As PrintPageEventArgs)
If OperatingSystem.IsWindows Then
ppea.Graphics.DrawImage(Image.FromFile(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Berechnungsblatt.jpg"), ppea.Graphics.VisibleClipBounds)
ppea.HasMorePages = False
End If
End Sub
Sub FormScreenShot()
If OperatingSystem.IsWindows Then
Dim fullSizeBitmap = New Bitmap(Me.Width, Me.Height, PixelFormat.Format32bppArgb)
PictureBox1.Refresh()
PictureBox1.Invalidate()
PictureBox1.BackgroundImage = PictureBox1.Image
Me.DrawToBitmap(fullSizeBitmap, New Rectangle(Point.Empty, Me.Size))
fullSizeBitmap.Save(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Berechnungsblatt.jpg")
End If
End Sub
Private Sub DruckenToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles DruckenToolStripMenuItem1.Click
FormScreenShot()
If OperatingSystem.IsWindows Then
Try
AddHandler PrintDocument1.PrintPage, AddressOf Me.PrintImage
PrintDocument1.DefaultPageSettings.Landscape = True
PrintDocument1.Print()
MessageBox.Show("Es wird gleichzeitig eine Kopie auf Ihrem Desktop zur weiteren Verwendung/Ablage erstellt")
Catch ex As Exception
MessageBox.Show("Prüfen Sie, ob ein Drucker angeschlossen ist")
End Try
End If
End Sub
Private Sub KopieAufDesktopToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles KopieAufDesktopToolStripMenuItem.Click
FormScreenShot()
End Sub
Private Sub TextBox16_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox16.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Asc(e.KeyChar) <> 44 AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Bitte tippen Sie Zahlen ins Feld!")
e.Handled = True
End If
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If OperatingSystem.IsWindows Then
RemoveHandler PrintDocument1.PrintPage, AddressOf Me.PrintImage
End If
End Sub
End Class
-
Apr 19th, 2025, 04:31 AM
#12
Re: vb.net published program crashes when drawing into picturebox
 Originally Posted by Gangstertom
Now we are standing in front of the next problem.
So mark this thread Resolved (using the Thread Tools menu) and start a new thread for the new problem, containing only the information relevant to the new problem, including a title. One thread per topic and oine topic per thread. For the record, every line of your code is not relevant to any problem. If you can't narrow it down much further than that then you haven't tried. If you need to create a new test program that isolates just the functionality relevant to this specific problem then that's what you do. That's a very common part of debugging code, so it's something you should be doing before posting here. If you can't fix the issue, you show us the relevant code from the test program, which doesn;t contain all the irrelevant noise.
-
Apr 19th, 2025, 09:52 AM
#13
Thread Starter
New Member
Re: vb.net published program crashes when drawing into picturebox
ok, i understand that i should open a new thread for the new situation, but i got no answer for my question, if anybody could explain, why the program had crashed on that specific windows 10 pro computer. I don't think its a code problem, because the program is working well on different PCs. But anyway, thank You for Your help, thread resolved.
-
Apr 19th, 2025, 10:45 AM
#14
Re: [RESOLVED] vb.net published program crashes when drawing into picturebox
Refresh is a reserved keyword in VB.Net. I'm not sure if that caused your error, but it certainly didn't help...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|