Das Notes Forum

Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: wuwu am 03.03.05 - 14:00:43

Titel: Maximum ermitteln
Beitrag von: wuwu am 03.03.05 - 14:00:43
Hallo,

ich habe hier im Forum und in der Hilfe gesucht, leider nicht fündig geworden:

Ich durchlaufe eine Ansicht, GetAllDocuemntsbyKEY usw.
While Not(v_doc Is    Nothing)
      var = var & v_doc.work_plan_follow_nr(0) & Chr(10)
      Set v_doc =dc.GetNextDocument(v_doc)   
   Wend
   Messagebox var

Hier gibt er mir 3 Werte in der Messagebox aus: 10, 20, 30, untereinander aufgelistet.

Ich schaffe es nicht, das er mir den größten(maximum) Wert des Feldes work_plan_follow_nr(0) ausgibt, also nur 30! Wie geht das?

Danke, mfg horst
Titel: Re: Maximum ermitteln
Beitrag von: dirk_2909 am 03.03.05 - 14:05:53
Hallo

lngMaxWert = 0

while not( doc is Nothing )

   if doc.work_plan_follow_nr( 0 ) > lngMaxWert Then
      lngMaxWert  = doc.work_plan_follow_nr( 0 )
   end if

wend

msgbox cstr( lngMaxWert )


Ich denke es müsste so gehen.

Dirk
Titel: Re: Maximum ermitteln
Beitrag von: umi am 03.03.05 - 14:08:02
Da war jemand schneller :-)

Hi
1. ist das Feld work_plan_follow_nr ein Mehrfachfeld?

ansonsten könntest Du mit ungefähr wie folgt verfahren
dim max as integer
dim value as integer
max = 0
while ()
value = cint(v_doc.getitemvalue("Work_Plan_Follow_NR")(0))
if value>max then
max = value
end if
wend
messagebox cstr(max)
Titel: Re: Maximum ermitteln
Beitrag von: wuwu am 03.03.05 - 14:31:35
Hallo,
danke für eure Hilfe, ein Problem habe ich noch, er läuft mir jetzt in eine Endlosschleife, warum?

Sub Click(Source As Button)
   On Error Goto haendler
   
   Dim session As New NotesSession
   Dim db As notesdatabase
   Set db = session.CurrentDatabase   
   
   Dim dc As NotesDocumentCollection
   Dim view As NotesView
   Dim v_doc As NotesDocument   
   
   
   Dim ws As New NotesUIWorkspace
   Dim uidoc As notesuidocument
   Dim doc As NotesDocument
   
   Set uidoc = ws.CurrentDocument
   Set doc = uidoc.Document
   
   Set view = db.GetView("$pm_work_plan")
   Set dc = view.GetAllDocumentsByKey(doc.ParentDocumentUNID)
   Set v_doc = dc.GetFirstDocument
      
   Dim max As Integer
   Dim value As Integer
   max = 0
   While Not(v_doc Is    Nothing)
      value = Cint(v_doc.getitemvalue("Work_Plan_Follow_NR")(0))
      If value>max Then
         max = value
      End If
   Wend
   Messagebox Cstr(max)
   Exit Sub
haendler:
   Msgbox Error() & " / Zeile: " & Erl() & " (Modul:QuerySave)"
   Exit Sub
End Sub
Titel: Re: Maximum ermitteln
Beitrag von: koehlerbv am 03.03.05 - 14:36:42
Weil Du das erste instantiierte Doc immer wieder in der While Wend-Schleife verwendest  ;D
Titel: Re: Maximum ermitteln
Beitrag von: wuwu am 03.03.05 - 14:56:22
Hallo,
das ist die Lösung, ich bin heute schon zu lange davor gesitzt!
Danke nochmals für eure Hilfe!!

lngMaxWert = 0
      
      While Not( v_doc Is Nothing )
         
         If v_doc.work_plan_follow_nr( 0 ) > lngMaxWert Then
            lngMaxWert  = v_doc.work_plan_follow_nr( 0 )
         End If
         Set v_doc =dc.GetNextDocument(v_doc)   
      Wend
      
      Msgbox Cstr( lngMaxWert )