Jump to content

Featured Replies

Posted

hey folks,

 

in vb:

Dim a As Integer
a = a Or &H80

 

ok the first line is clear, but the second line im not sure about. can somebody type it in pseudo code?

 

it seems like the &H80 is nothing more than hex value for decimal 128. i dont know why i would type:

a can be a or 128

 

i mean, its not commented, i would understand it this way. why would the interpreter care if i tell him, a can be either a or 128 lol. i dont get it.

 

second prob:

 

n = 8: d = 0

 

lol wtf!!!

why would you do a = a or the value?

 

make a if statement

 

if this happens then

a = a

else

a = &H80

end if

 

and yes you can do

 

a = 128

 

if it suits you.

 

no idea about the second one, thats wierd.

  • Author

whats wrong with ppl these days when it comes to reading.

 

i dont want to do an if statement and i dont want to set x = y u idiot.

 

read my posting again, i know my english is not the best but its pretty obivous what i am asking for.

its not too obvious to me......

 

its very late tho...

 

maybe be specific as to what you are trying to accomplish, i could probably help more then.

  • Author

ok,

 

a = a Or &H80

 

  [myg0t said:
nimrod]

can somebody type it in pseudo code?

 

it seems like the &H80 is nothing more than hex value for decimal 128. i dont know why i would type:

a can be a or 128

 

second prob:

 

n = 8: d = 0

whats the meaning of this line in pseudocode? it doesnt make any sense to me.

I've only dabbled in VB (required course at college), so I'm far from an expert...

 

a = a Xor &H80

 

and

 

a = a Or &H80

 

both end up assigning "128" to a... an 'exclusive or' should never assign a value like that :x, what the "Or" attempts to accomplish, I have no clue

 

a = a And &H80 displays "0", which is correct (assuming "undefined" = null/zero/false, which i'm guessing is the case here)

 

I have no idea why the first 2 work as they do though. ^^ Where the hell did you see that in the first place?

  asterix said:
I've only dabbled in VB (required course at college), so I'm far from an expert...

 

a = a Xor &H80

 

and

 

a = a Or &H80

 

both end up assigning "128" to a... an 'exclusive or' should never assign a value like that :x, what the "Or" attempts to accomplish, I have no clue

 

a = a And &H80 displays "0", which is correct (assuming "undefined" = null/zero/false, which i'm guessing is the case here)

 

I have no idea why the first 2 work as they do though. ^^ Where the hell did you see that in the first place?

 

who cares where its starting to confuse me as well lol

  • Author
  asterix said:
I have no idea why the first 2 work as they do though. ^^ Where the hell did you see that in the first place?

 

at first, thanks for the first serious and usable answer. actually im porting a vb app to pascal. so i have to deal with vb syntax which is totally new to me. most of the crap is understandable, but well these two examples give me a headache, especially the second one.

i googled for a certain time and found examples of course, but not by anyone who commented his code. maybe the vb author is doing something wrong, i dunno. he claims his app works for him, it doesnt for me, thats why im redoing it =). i still need to figure the second issue out: n = 8: d = 0 WTF?

Is it VB6 or VB .NET?

 

Because the logical operators (and, or, not) are handled differently in each version (according to google)

 

As far as I can tell, and in the all the examples I've seen, that

 

Dim a As Integer
a = a Or &H80

 

SHOULD be equivalent to

 

C-style code:

int a;

if(a == true || &H80 == true) {
a = true;
} else {
a = false;
}

 

a has no value initially, so it is false, but &H80 is 128, which is non-zero and thus "true"... why it assigns 128 to a, I don't know. ^^ Maybe because it is an integer and not boolean? In all the examples I've seen using "Or", the coder has used a boolean variable for it.

 

Is there any more of the code you can post, or was that all? Does a receive any values in between being declared and the assignment statement that has you confused? How is it used after the "or" operation?

  • Author

this is the complete procedure:

Private Sub spisend(a As Integer, d As Integer)
Dim p, n, x As Integer
p = Val(portsel.Text)
a = a Or &H80
For x = 7 To 0 Step -1
   If (a And (2 ^ x)) <> 0 Then n = 8 Else n = 0
   Out p, n
   Out p, n + &H80
Next
For x = 7 To 0 Step -1
   If (d And (2 ^ x)) <> 0 Then n = 8 Else n = 0
   Out p, n
   Out p, n + &H80
Next
End Sub

 

thx for your effort. i of course posted in vb forums as well, at the same time i posted here. i didnt get any reply yet though. man where are all the vb coders when u need them? ^^

 

dont waste any time on this m8, when i google about it should be enough. the second issue still gives me a headache.

Guest
This topic is now closed to further replies.