Page 2 of 2 FirstFirst 12
Results 41 to 52 of 52

Thread: [RESOLVED] About a single instance of a For Next loop

  1. #41

    Thread Starter
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,855

    Re: About a single instance of a For Next loop

    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
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern |

    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, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  2. #42
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,971

    Re: About a single instance of a For Next loop

    Quote Originally Posted by ThEiMp View Post
    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
    Out of interest could you post your solution? I am intrigued to see how a single iteration loop would work when no loop at all wouldn't.

  3. #43

    Thread Starter
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,855

    Re: [RESOLVED] About a single instance of a For Next loop

    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
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern |

    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, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  4. #44
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,971

    Re: [RESOLVED] About a single instance of a For Next loop

    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

    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
    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....
    Last edited by PlausiblyDamp; Jun 12th, 2022 at 02:16 PM.

  5. #45

    Thread Starter
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,855

    Re: [RESOLVED] About a single instance of a For Next loop

    But then it works, right for the time being, then
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern |

    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, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  6. #46
    Frenzied Member
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    1,646

    Re: [RESOLVED] About a single instance of a For Next loop

    So.

    By the power invested in me, all the threads I start are Niya and Olaf free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  7. #47
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,971

    Re: [RESOLVED] About a single instance of a For Next loop

    Quote Originally Posted by ThEiMp View Post
    But then it works, right for the time being, then
    You have a strange definition of "works" then. I dread to think how many subtle (or not subtle) bugs are lurking in that code.

  8. #48
    Addicted Member
    Join Date
    Oct 2011
    Posts
    179

    Re: [RESOLVED] About a single instance of a For Next loop

    In cargo cult programming it is OK to have code that has no sense as long as the program works.

  9. #49
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,971

    Re: [RESOLVED] About a single instance of a For Next loop

    Quote Originally Posted by argen View Post
    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.

  10. #50
    Addicted Member
    Join Date
    Oct 2011
    Posts
    179

    Re: [RESOLVED] About a single instance of a For Next loop

    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.

  11. #51
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,275

    Re: [RESOLVED] About a single instance of a For Next loop

    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...

  12. #52
    Addicted Member
    Join Date
    Oct 2011
    Posts
    179

    Re: [RESOLVED] About a single instance of a For Next loop

    Quote Originally Posted by OptionBase1 View Post
    he's probably just doing the best he can...

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width