Private Sub TimerZoominOut_Tick(sender As System.Object, e As System.EventArgs) Handles TimerZoominOut.Tick
        
Dim zoom = Document.ZoomFactor

        Select Case zoom

            Case zoom = 63
                toolBar_zoomin.Enabled = False
            Case zoom < 63
                toolBar_zoomin.Enabled = True
            Case zoom = 1
                toolBar_zoomOut.Enabled = False
            Case zoom > 1
                toolBar_zoomOut.Enabled = True


        End Select

    End Sub

I want the buttons to disable/enable and the correct point. the Document is actually a richtextbox. However it does not seem to work. I don't know what I am doing wrong. Maybe someone can tell me where I have gone wrong.

Thanks
CE

CriticalError
Deleted Member

Your "Case zoom = 1" and "Case zoom > 1" may never get executed. If zoom = 1 then it will get processed by the "Case zoom < 63" clause. If zoom = 12 then "Case zoom < 63" will also trap it. You'll have to define your case clauses more precisely. Perhaps

toolBar_zoomOut.Enabled = zoom > 1
toolbar_zoomIn.Enabled = zoom < 63

would work better.

Edited 4 Years Ago by Reverend Jim: n/a

I am sure I replied to this topic yesterday, looks like it never got through.

Anyway I tried this, yours was quite confusing for me (no offence)

Private Sub TimerZoominOut_Tick(sender As System.Object, e As System.EventArgs) Handles TimerZoominOut.Tick
        Dim zoom = Document.ZoomFactor


        Select Case zoom

            Case Is = 63
                toolBar_zoomin.Enabled = False

            Case Is = 1
                toolBar_zoomOut.Enabled = False


            Case Else
                toolBar_zoomin.Enabled = True
                toolBar_zoomOut.Enabled = True

        End Select

The only problem with this now is that, when it is disabled, (zoom in or out) the other one will not work, So if zoom in is disabled zoom out is enabled but does not function.

The timer is set to enabled and interval is set to 1

You don't need to put the code into a timer. It can be put into the hadler for the zoom click event(s). In pseudo code it looks like

Private Sub zoom_IN
 
   'put zoom in processing code here

    toolBar_zoomOut.Enabled = zoom > 1
    toolbar_zoomIn.Enabled = zoom < 63

End Sub

Private Sub zoom_OUT
 
   'put zoom out processing code here

    toolBar_zoomOut.Enabled = zoom > 1
    toolbar_zoomIn.Enabled = zoom < 63

End Sub

"zoom > 1" evaluates to True if zoom is greater than 1 and False otherwise. This is a concise statement of

If zoom > 1 Then
   toolBar_zoomOut.Enabled = True
Else
   toolBar_zoomOut.Enabled = False
End If

In other words "If we aren't zoomed out as far as possible then enable the zoom out button".

OK Thanks I understand now.

This question has already been answered. Start a new discussion instead.