문제

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

도움이 되었습니까?

해결책

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 

다른 팁

The question relates to 'short circuit' evaluation of condition expressions. Well VB6 does not support this feature. I know this is stupid.

While Not RdoRst.EOF 
    If RdoRst(2) = "Foo" Then
        cboComboBox.AddItem RdoRst(1) 
        cboComboBox.ItemData(cboComboBox.NewIndex) = RdoRst(0) 
    Else
        Exit Wend
    End If
    RdoRst.MoveNext 
Wend
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top