views:

51

answers:

2

Hi,

I would like something like that :

While Not RdoRst.EOF And RdoRst(2) = "Foo"
        cboComboBox.AddItem RdoRst(1)
        cboComboBox.ItemData(cboComboBox.NewIndex) = RdoRst(0)
        RdoRst.MoveNext
Wend

I want that the expression 1 (Not RdoRst.EOF) is evaluated first. Then if it returns true, the expression 2 is evaluated too (RdoRst(2) = "Foo"). If expression 1 return false, the expression 2 is not evaluated.

Regards,

Florian

A: 

AndAlso is not available in VB6. Try this

Do 
  If RdoRst.EOF Then Exit Do 
  If Not RdoRst(2) ="Foo" Then Exit Do      
  cboComboBox.AddItem RdoRst(1)  
  cboComboBox.ItemData(cboComboBox.NewIndex) = RdoRst(0)  
  RdoRst.MoveNext  
Loop 
MarkJ
A: 

While Not RdoRst.EOF If RdoRst(2) = "Foo" Then cboComboBox.AddItem RdoRst(1) cboComboBox.ItemData(cboComboBox.NewIndex) = RdoRst(0) End If RdoRst.MoveNext Wend

Mike Cheel
Good idea, but doesn't your code behave differently from the code in the question? Code in the question stops looping immediately when a non-Foo value is found. Your code keeps on looping in the hopes of finding another Foo.
MarkJ
You're right I should have put ELSE Exit Wend
Mike Cheel