Hallo
@Stephan
Dein Basiccode läuft in modifizierter Form etwa 35 sec bis zur Bereichssumme 100.
Code: Alles auswählen
Sub Finde_Kombination()
With ThisComponent.Sheets().GetByName("Tabelle1")
For a = 0 To 37
.getCellByPosition(1, 1).Value = a 'B2
For b = 0 To 37
.getCellByPosition(2, 1).Value = b 'C2
For c = 0 To 37
.getCellByPosition(3, 1).Value = c 'D2
For d = 0 To 37
.getCellByPosition(4, 1).Value = d 'E2
For e = 0 To 37
.getCellByPosition(5, 1).Value = e 'F2
For f = 0 To 37
.getCellByPosition(6, 1).Value = f 'G2
If .getCellByPosition(7,1 ).Value = 100 Then 'BC27
Msgbox "Passende Werte gefunden"
Exit Sub
End If
Next f
Next e
Next d
Next c
Next b
Next a
End With
End Sub
Der dazu analoge Code in Python benötigt gerademal 5sec weniger.
Code: Alles auswählen
import datetime
def main():
doc = context.getDocument()
sheets = doc.getSheets()
sheet = sheets.getByIndex(0)
cell = sheet.getCellByPosition
print datetime.datetime.now()
for a in range(38):
cell(0,0).setValue( a )
for b in range(38):
cell(1,0).setValue( b )
for c in range(38):
cell(2,0).setValue( c )
for d in range(38):
cell(3,0).setValue( d )
for e in range(38):
cell(4,0).setValue( e )
for f in range(38):
cell(5,0).setValue( f )
if cell(6,0).getValue() == 100:
print datetime.datetime.now()
return
Auch in der Form findet keine
sichtbare Aktualisierung statt, die Bereichssumme wird aber offenbar registriert.
Karo