Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set flags

Status
Not open for further replies.

jamesoc

Technical User
Feb 1, 2005
38
IE
how would you set a flag in vb6.what i want to do is set a flag to false and when a certain condition occurs set it to true
 
You have to declare a boolean variable:

Code:
'declare
Dim blnFlagName as boolean
'initialize to false
blnFlagName = false
'some code passes, check condition
blnFlagName = MyConditionFunction

-Max
 
>You have to ...

Not necessarily (although it does make things clearer)
 
For example:
Code:
dim myFlag as integer
myFlag = cInt(myCondition = True)
This will set myFlag to -1 if the condition is true, and 0 if not.
 
how would i set a flag to be edge triggered ie
when the condition is false the flag remains at 0 ,when the condition is true the flag is set to 1 and a task is carried out and the flag remains at 1 but when the condition changes back to false 0 the same task carried out when the flag was set is then carried out again

!_____!
----- -------
 
this is what i want to do



1.check each individual pixel in a certain row
2.if the pixel is vbwhite check next pixel
3.if the pixel is vbblack display the position in a textbox
4.when the pixel returns to vbwhite display the position in the textbox
5.when the pixel returns to vbblack again display the position
and carry on like this till the end of the row

as the image is made up of pixels either vbblack or vbwhite
and only one row of pixels is being scanned there should not be to many positions displayed
i can check each pixel in a certain row for the color value
thx
 
to check for difference between different images
 
this is the code i am trying to use
Private Sub Command3_Click()
Dim i As Long, Colr As Long
Dim count1 As Long

Pic.ScaleMode = vbPixels

Colr = vbBlack
For i = 0 To Pic.ScaleWidth - 1
If Pic.Point(i, 190) = Colr Then
Pic.PSet (i, 190), &HFFC0&
count1 = count1 + 1
ElseIf Pic.Point(i + count1, 190) = RGB(0, 0, 0) Then
MsgBox count1

End If

instead of message boxing the result for count i would like to put them in a text box .
i thought text1.txt=count1 would work but i seem to be having trouble
 
You are overwriting the existing value:
text1.txt=count1
If you want them on the same line:
text1.text=text1.text & " " & tcount1
or each on its own line
text1.text=text1.text & vbcrlf & tcount1

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
this is what i need and its recking my head ive tried numerous different ways but cant get it to work

w=white pixel
b=black pixel

of pixels in image in a picture box

for that line i need a text box to display
6,8
12,13
16,16
any help would be great
 
Have you tried simulating that output without actually checking of the picture? Perhaps the problem you are running into is not your picture code the text itself. I would also suggest a richtextbox instead of simple text box, sometimes they are easier to deal with.
-Max
 
I've used your text representation of the pixel colours to put the following together:

Code:
Const Black = "b"
Const White = "w"

Private Sub Command0_Click()

Dim count As Long
Dim picture As String

  picture = "[URL unfurl="true"]wwwwwbbbwwwbbwwbw"[/URL]
  Text1 = ""
  count = 1
  Do While count < Len(picture)
    If Mid(picture, count, 1) = Black Then
      If Text1 <> "" Then Text1 = Text1 & ", "
      Text1 = Text1 & count & "->"
      count = count + 1
      Do While Mid(picture, count, 1) = Black
        count = count + 1
      Loop
      count = count - 1
      Text1 = Text1 & count
    End If
    count = count + 1
  Loop
  
End Sub

Hope this helps.
 
Not tested, I just modified my earlier code and combined a bit of yours - it will almost certainly need some editing

Code:
Dim count As Long

  Text1 = ""
  count = 0
  Do While count < Pic.ScaleWidth 
    If Pic.Point(count,190) = Black Then
      If Text1 <> "" Then Text1 = Text1 & ", "
      Text1 = Text1 & count & "->"
      count = count + 1
      Do While Pic.Point(count,190) = Black 
        count = count + 1
      Loop
      count = count - 1
      Text1 = Text1 & count
    End If
    count = count + 1
  Loop

don't forget to set the constant used for Black

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top