Announcement

Collapse
No announcement yet.

Primzahlen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Primzahlen

    Sub Zahlenfelderzeugung()
    l = 100
    zeile = 1
    spalte = 2
    For i = 2 To l
    Worksheets(1).Cells(zeile, spalte).Value = i
    spalte = spalte + 1
    If spalte = 11 Then
    spalte = 1
    zeile = zeile + 1
    End If
    Next
    colorf = 3
    zeile = 1
    spalte = 2
    Value = Worksheets(1).Cells(zeile, spalte).Value
    For a = Value To Int(Sqr(l))
    If Not Worksheets(1).Cells(zeile, spalte).Interior.ColorIndex Like "[1,colorf]" Then
    Call Markieren(Value, colorf, l)
    colorf = colorf + 1
    End If
    spalte = spalte + 1
    If spalte = 11 Then
    spalte = 1
    zeile = zeile + 1
    End If
    Value = Worksheets(1).Cells(zeile, spalte).Value
    Next
    End Sub
    Sub Markieren(Value, colorf, l)
    spalte = CInt(Right(Value, 1))
    If spalte = 0 Then spalte = 1
    zeile = 1
    For a = 2 To l
    If Worksheets(1).Cells(zeile, spalte).Value = Empty Then Exit For
    If Worksheets(1).Cells(zeile, spalte).Value Mod Value = 0 And Value <> Worksheets(1).Cells(zeile, spalte).Value Then
    If Worksheets(1).Cells(zeile, spalte).Interior.ColorIndex = -4142 Then
    Worksheets(1).Cells(zeile, spalte).Interior.ColorIndex = colorf
    End If
    End If
    spalte = spalte + 1
    If spalte = 11 Then
    spalte = 1
    zeile = zeile + 1
    End If
    Next
    End Sub

    könnt ihr mir den code so ändern, dass die farbe gelöscht wird und dafür nichts im kästchen steht?
    upload.wikimedia.org/wikipedia/de/d/dc/Animation_schnell_-_Sieb_des_Eratosthenes.gif <- also so wie in dem bild, nur dass die kästchen, die bunt werden value = "" bekommen und dass nur die primzahlen da stehen

    Edited
    Zuletzt editiert von Sadowman; 12.06.2009, 18:53. Reason: vertippt

  • #2
    In welchem Bild??
    Christian

    Comment


    • #3
      Soll das Code sein? Dafür gibt es mindestens den #-Button, damit das auch als Code lesbar ist.

      Soll das VB.NET sein oder "altes" VB?

      Wo sind Kästchen?

      Jürgen

      Comment

      Working...
      X