vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
SEPA-Dateien erstellen inkl. IBAN-, BLZ-/Kontonummernprüfung  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Ein- und Umsteiger
Re: Division 
Autor: Silver
Datum: 23.06.06 18:17

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
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Division1.349Manis22.06.06 20:38
Re: Division905Christoph197222.06.06 21:53
Re: Division894Manis23.06.06 11:58
Re: Division993Visual Basic Fan23.06.06 13:29
Re: Division915Visual Basic Fan23.06.06 15:04
Re: Division905Manis23.06.06 15:44
Re: Division925Visual Basic Fan23.06.06 17:51
Re: Division926Manis26.06.06 12:24
Re: Division900Visual Basic Fan26.06.06 16:11
Re: Division914Manis26.06.06 16:29
Re: Division913Visual Basic Fan26.06.06 16:33
Re: Division930Manis28.06.06 13:52
Re: Division885macgee28.06.06 19:49
Re: Division906Visual Basic Fan28.06.06 20:04
Re: Division1.108Visual Basic Fan28.06.06 20:09
Re: Division918macgee28.06.06 20:11
Programmierer894Visual Basic Fan28.06.06 20:29
Re: Division1.021Manis29.06.06 16:58
Re: Division984Silver23.06.06 18:17
Re: Division935Visual Basic Fan23.06.06 22:26
Re: Division881Silver23.06.06 22:30
Re: Division901Visual Basic Fan23.06.06 22:33
Re: Division916Manis26.06.06 12:46
Re: Division937Silver26.06.06 12:53
Re: Division936Manis26.06.06 13:40

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel