Thanks dudes, you were good help for me to get my single instance for ... next statement block, to be written right. This has been achieved and then now i am going to mark this thread, resolved, then so
Printable View
Thanks dudes, you were good help for me to get my single instance for ... next statement block, to be written right. This has been achieved and then now i am going to mark this thread, resolved, then so
Okay then here it is, like so:
Code:Option Explicit
'
Dim PauseTime, Start, Finish, TotalTime
Dim strBuff As String
Dim m_Marker As Byte
Dim OneTime As Boolean
Dim a As Integer
Dim b As Integer
'
Public Property Get Marker() As Byte
On Error Resume Next
m_Marker = m_Marker
End Property
Public Property Let Marker(ByVal New_Marker As Byte)
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
b = 0
b = b + 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" & b, "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 b = 11 Then m_Marker = "B"
strBuff = ""
OneTime = True
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", "A")
End With
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
On Error Resume Next
With PropBag
Call .WriteProperty("Marker", m_Marker, "A")
End With
End Sub
Does that really work as intended? You have still left a lot of the issues in there that were previously pointed out to you...
just a few, I have added comments to the code itself
There still seems to be a lot of potential problems, and I still don't see how a loop that runs only once by design makes any sense....Code:Option Explicit
'
Dim PauseTime, Start, Finish, TotalTime 'Did you mean to use variants?
Dim strBuff As String
Dim m_Marker As Byte
Dim OneTime As Boolean
Dim a As Integer
Dim b As Integer
'
Public Property Get Marker() As Byte
On Error Resume Next ' why? this is dangerous normally, pointless here
m_Marker = m_Marker 'This achieves nothing, a Get should return something as well.
End Property
Public Property Let Marker(ByVal New_Marker As Byte)
On Error Resume Next ' why? this is dangerous normally, pointless here
m_Marker = New_Marker
PropertyChanged "Marker"
End Property
Private Sub UserControl_Initialize()
On Error Resume Next 'This is going to hide any errors in this sub, probably not a good idea!
1 If OneTime = False Then 'Label 1 is never used anywhere, this is the only place OneTime is referred to and will always be false so no need for the If statement anyway
For a = 1 To 1 'How is this any different to not having a loop though?
b = 0
b = b + 1 'Why not just set b = 1, as this is never going to execute more than once
PauseTime = 6
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop 'Busy loops like this are normally a bad idea
Finish = Timer
TotalTime = Finish - Start
If TotalTime = 0 Then GoTo 2 'Does nothing, it would go to the next line anyway.
2 strBuff = StrConv(LoadResData("EP" & b, "VIDEO"), vbUnicode) 'Treating binary data as a string???
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 'Busy loop again
Finish = Timer
TotalTime = Finish - Start
If TotalTime = 0 Then GoTo 3 'Again does nothing as it would go to the next line anyway
3 If b = 11 Then m_Marker = "B" 'how will it ever be 11 if you start and 1 and only run the loop once? Also Marker is a byte, why are you assigning a string?
strBuff = ""
OneTime = True
Next a
Else
Exit Sub
End If
End Sub
Private Sub UserControl_Resize()
On Error Resume Next 'Hiding potential errors
With UserControl
.Height = 330
.Width = 435
End With
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
On Error Resume Next 'Hiding potential errors
With PropBag
m_Marker = .ReadProperty("Marker", "A") 'm_Marker is a Byte, why assign a string / character?
End With
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
On Error Resume Next 'Hiding potential errors
With PropBag
Call .WriteProperty("Marker", m_Marker, "A")
End With
End Sub
But then it works, right for the time being, then
So.
:wave:
In cargo cult programming it is OK to have code that has no sense as long as the program works.
Perhaps I tend to be a bit obsessive about these things... I know that no code is likely to be perfect, we all make unintentional mistakes; but I could never just ignore code with blatant mistakes and problems.
The thought of deliberately writing code that is hard to read, contains pointless conditionals that don't change the code flow, getters that don't return anything, control initialisers that are potentially writing out massive video files and not actually doing any control initialisation, etc. just goes against everything I have learned and practiced over the past thirty something years.
Yes, I know, and I agree. But I mean that there are some people that don't want to understand programming, just want things that work and don't care how or why.
Right, but if you look at the threads the OP has created over the past many, many years, they often are him asking for feedback or suggestions on his code, him getting a tremendous amount of suggestions, and him implementing exactly zero of them.
My conclusion is, he's probably just doing the best he can...