Dear Members of the Forum.
I wish to know how to write a For Next loop, that only works in a single instance.
Here is what i am working with, as of late:
!! Thanks in advance !!Code:Dim a As Integer
a = 0
For a = 1 to 1
.
.
.
Next a
Printable View
Dear Members of the Forum.
I wish to know how to write a For Next loop, that only works in a single instance.
Here is what i am working with, as of late:
!! Thanks in advance !!Code:Dim a As Integer
a = 0
For a = 1 to 1
.
.
.
Next a
If you have a hardcoded start value which is equal to the end value then you don’t need a for next loop.
Just assign your variable to the start value
you don't need For Next Loop for a single instance.
the handler keeps on firing up, on the multipul file extractions of the resource file. which i only want the first one in the library resource file. to work on at a single instance moment in time, if that is possible. then why wouldn't it, be then possible???
if u want a function to just be used 1 time,
u can add "Static"..
Static OneTime as Boolean
Dim a As Integer
if OneTime = False then
For a = 1 to 1
.
.
.
Next a
OneTime = True
end if
and if u want to be able to "reset" it
Sub MyFunction(Optional Byval Reset As Boolean)
If Reset Then OneTime = False
Thanks dude, for the input, so
I'm working on something that looks like this:
Code:Option Explicit
'
Dim PauseTime, Start, Finish, TotalTime
Dim strBuff As String
Dim m_Marker As Byte
Static OneTime As Boolean
Dim a As Integer
'
Public Property Get Marker() As String
On Error Resume Next
m_Marker = m_Marker
End Property
Public Property Let Marker(ByVal New_Marker As String)
On Error Resume Next
m_Marker = New_Marker
PropertyChanged "Marker"
End Property
Private Sub UserControl_Initialize()
On Error Resume Next
1 If OneTime = False Then
For a = 1 To 1
If a = 0 Then
a = 0
a = a + 1
PauseTime = 6
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
If TotalTime = 0 Then GoTo 2
2 strBuff = StrConv(LoadResData("EP" & a, "VIDEO"), vbUnicode)
Open "C:\Temp\zVideo-1234567890.mkv" For Output As #1
Print #1, strBuff
Close #1
PauseTime = 6
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
If TotalTime = 0 Then GoTo 3
3 If a = 11 then m_Marker = "B"
strBuff = ""
OneTime = True
Else
Exit Sub
End If
Next a
Else
Exit Sub
End If
End Sub
Private Sub UserControl_Resize()
On Error Resume Next
With UserControl
.Height = 330
.Width = 435
End With
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
On Error Resume Next
With PropBag
m_Marker = .ReadProperty("Marker", "")
End With
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
On Error Resume Next
With PropBag
Call .WriteProperty("Marker", m_Marker, "")
End With
End Sub
the code is so strange and just wrong.
a will never and can never be 0 it will always start as 1.Code:For a = 1 To 1
if a = 0 Then
if you want to run 2 times, u should instead do:
would run it once.Code:For a = 0 To 1
if a = 0 Then
if you instead do:
it will loop infinitely. 1>0>1>0 etc.Code:For a = 1 To 1
a = 0
Next a
I assume theres something between this 2 lines right? otherwise it makes no sense.Code:If TotalTime = 0 Then GoTo 2
2
also, UserControl_Initialize is only run once.
if u want to make it global (if u have multiple instances of the class) you will need a public variable outside the class.
so in a module: Public RunOnlyOnce as Boolean
Why are you just setting m_Marker to itself and not returning anything from a property get? Why is the property a string but m_Marker a Byte? This makes no sense at all.
So if m_Marker is a Byte why does the property accept a string which you directly assign to a byte?
What on earth are you trying to do here? Why are you trying to loop only once - that isn't a loop. Why do you have such a convoluted way of checking and setting the variable a? Especially as it will never be 0 in the first place!
Why are you doing a pause immediately? You haven't done anything that needs a pause yet, but you are pausing. You are also doing a pause the worst way (DoEvents in a loop), and then doing a check which will take you to the same place regardless as label "2" immediate follows this code!
A mkv file is a binary file, why are you writing out a string in this case?
Another bad delay that has a pointless If ... Goto that will not alter the code flow
How will "a" ever be 11? Why are you assigning a string to a byte again?
I have no idea what the code is trying to do but it sems to make no sense at all. Why do you think you need a loop to do something once?
Hmmm.. So you are telling it A=1 then you are checking to see if A=0 even though you have just set it to 1Code:For a = 1 To 1
If a = 0 Then
a = 0
a = a + 1
You then if say if A=0 then let's set A=0 then let's set A=A+1 which since you just set it to 0 means you are setting it to 1 but it already was set to one just a couple of lines before.
Makes me wonder if you have ever written a working line of code before.
Then you have these wierd gotos like
Again that if ... goto does nothing the code will always goto line 2 because that is the next line same for the one you have that goes to line 3 Very strange.Code:If TotalTime = 0 Then GoTo 2
2 strBuff = StrConv(LoadResData("EP" & a, "VIDEO"), vbUnicode)
That entire loop will basically do nothing at all and I use the term loop very lightly as it is not really a loop at all either since it will never loop it can't really be called a loop.
This code would do the same thing as the code you have shown for that sub
Code:Private Sub UserControl_Initialize()
End Sub
Look at his other posts...there you will find the answer! ("No")Quote:
Makes me wonder if you have ever written a working line of code before.
ThEiMp is living in a parallel universe, where all laws and logic is scattered around in total chaos.
nothing makes sense for us. but for him, we are the strange ones.
The thing with this snippet of source code is to only proceed if the value of TotalTime = 0. however if the value of TotalTime isn't equal to 0, then it will exit the loop and then only work with the value, when and only when it equals zero, then so. this is set in stone, because of the DoEvents command, found inside the loop, in the above block of source code, of mine. And then also, i have written the line of code, whch is m_Marker = "B". This means for Director to then move to the B Marker of the score window.Code:If TotalTime = 0 Then GoTo 2
2 blah blah
That isn't what your code does though, at no point do you exit the loop and the goto achieves nothing! Why do you think it will exit the loop?
I don't think the DoEvents command does what you think it does, it certainly has nothing to do with exiting loops....
That doesn't make much sense either, it also doesn't explain why the Marker property Get is completely wrong, or why you are mixing string and byte data types.
i just used a wizard for the creation of the m_Marker property, then so
Im starting to suspect ThEiMp is just a fake account from some member here playing a joke on everyone.
I mean the absurdity is extreme. he joined 2007 and the level is below a newbie. Its negative. how can u even get at that level?
JFYI, from his sig:
Quote:
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry. . .
Yes, it explains that he modified the code, without knowing what he is doing or what the implications are
Maybe the Moderators can take a look at this joker and do something about it???
I always thought this posting account was a broken and failed chatbot AI. Literally everything is nonsensical from it.
I'm heading for retirement in the next 3-4months, I won't miss these Thread(s)
what is wrong with this account of mine, it's works like i work at my workplace, then so
Then so! Even So. Fatso.
We also didn't match up against this little bug in my source code, then so???
Code:Dim m_Marker As Byte
Public Property Get Marker() As String
On Error Resume Next
m_Marker = m_Marker
End Property
Public Property Let Marker(ByVal New_Marker As String
On Error Resume Next
m_Marker = New_Marker
PropertyChanged "Marker"
End Property
Red: you should NOT mix Byte and String like that. use "THE SAME"Code:Dim m_Marker As Byte
Public Property Get Marker() As String
On Error Resume Next
m_Marker = m_Marker
End Property
Public Property Let Marker(ByVal New_Marker As String)
On Error Resume Next
m_Marker = New_Marker
PropertyChanged "Marker"
End Property
Blue: Please LOOK CAREFULLY. why assign a value from the same variable. ITS WRONG.
Purple: REMOVE. this will only make your code work but you don't SEE the error. YOU SHOULD NOT USE On Error like that.
thanks for the input
You didn't finish your sentence with "even so", is there something wrong, even so?
This ended once with "so."
"Even so, then so, also then so", or just plain "even" or "then" followed explanations.
"Then so" was used once in confusion, and the end of a following question within the same paragraph. The word "matey" smoothed the transition.
"So" and "so then" followed questions a couple of times, but "so then" also followed explanations, ending once with "guys!" :thumb:
"At that" was used a few times, but it has been retired like good-old "even." :(
"Otherwise so" was used once, but that could've been due to brain farts!
I also found "thus far as so," which felt like a discovery at the Mariana Trench!
I had a little time on my hands. :bigyello:
You are a right so-and-so.
There must be something in the OP's native language that adds these little grammar-farts to the end of sentences. Perhaps they have some subtle influence on the sentence that gives it all meaning, a meaning that we, mere English speakers, are missing.
OP - the reason we draw attention to this is because large parts of your sentences have errors. If you remove these "add-ons" from each sentence, it should (theoretically) improve our understanding.
Input, output, kaput!
oh brother!!
okay, i am reading you