Hallo!
Ich hab das mal versucht auf der Schnelle zu realisieren (nach Frühschicht und nur 4 Stunden Schlaf)....Das ist dabei rausgekommen:
Du benötigst hierfür:
2 Textboxen (Textbox1 und Textbox2, in der du die beiden Zahlen schreibst)
1 Button (Button1) und
1 Picturebox (Picturebox1)
Public Class Form1
Private xy As Integer
Dim myFont As New System.Drawing.Font("Comic Sans MS", 8)
Private Bit As System.Drawing.Bitmap
Private g As Graphics '= Graphics.FromImage(Bit)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
Dim x As Integer
Dim FontH As Integer = g.MeasureString("0", myFont).Height
Dim FontW As Integer = g.MeasureString("000", myFont).Width - _
g.MeasureString("00", myFont).Width
Dim zahl1 As Integer = CInt(TextBox1.Text)
Dim zahl2 As Integer = CInt(TextBox2.Text)
Dim Erg As Integer = zahl1 / zahl2
Dim Multi As New List(Of Integer)
Dim RunterIndex As Integer = 0
Dim runterlänge As Integer = 1
Dim Z1 As Integer = 0
Dim ErgebnisStelle As Integer
Dim zeile As Integer = 1
Dim rest As Integer = 0
xy = FontH
If FontW > XY Then XY = FontW
XY += 4
g.Clear(Color.White)
'Papier Zeichnen
For x = 0 To Bit.Width Step XY
g.DrawLine(Pens.LightGray, x, 0, x, Bit.Height)
Next
For x = 0 To Bit.Height Step XY
g.DrawLine(Pens.LightGray, 0, x, Bit.Width, x)
Next
TextOut(TextBox1.Text & ":" & TextBox2.Text & "=" & Erg.ToString(), 1, _
1)
Do
runterlänge = 1
Z1 = 0
While Z1 < zahl2 'And runterlänge + RunterIndex <
' TextBox1.Text.Length - 1
Z1 = CInt(TextBox1.Text.Substring(RunterIndex, runterlänge))
Z1 += rest * 10 ^ (Z1.ToString.Length)
runterlänge += 1
End While
ErgebnisStelle = (Z1 \ zahl2) * zahl2
TextOut(Z1.ToString, RunterIndex + runterlänge - _
Z1.ToString.Length, zeile)
TextOut(ErgebnisStelle.ToString, RunterIndex + runterlänge - _
ErgebnisStelle.ToString.Length, zeile + 1)
rest = Z1 - ErgebnisStelle
RunterIndex += runterlänge - 1
zeile += 2
Loop While rest <> 0 And RunterIndex < TextBox1.Text.Length
PictureBox1.Image = Bit
End Sub
Private Sub TextOut(ByVal text As String, ByVal x As Integer, ByVal y As _
Integer)
Dim RecF As New RectangleF
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
For x1 As Integer = 0 To text.Length - 1
With RecF
.X = xy + xy * (x + x1)
.Y = xy * y
.Width = xy
.Height = xy
End With
g.DrawString(text.Chars(x1), myFont, Brushes.DarkBlue, RecF, sf)
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
Bit = New System.Drawing.Bitmap(PictureBox1.Width, PictureBox1.Height)
g = Graphics.FromImage(Bit)
End Sub
End Class Gru?
Silver
Mein erstes Programm:
10 Print 'Hallo';
20 Goto 10
|