Well, not sure what example you want? If you don't understand the syntax, maybe you need to study the BASIC language from the beginning.
For part of your code, it should looks like
If up=1 Then
If bcount=0 Then bcount=255
If dn=1 Then
If bcount=255 Then bcount=0
You didn't port the debounce part from C code exactly. Maybe you are using your way.