Progressbar
Progressbar
Progressbar
Progressbar
Progressbar
Progressbar Progressbar Progressbar Progressbar Progressbar Progressbar Progressbar Progressbar
Progressbar Progressbar
Progressbar
Go Back  Xtreme Visual Basic Talk > > > Progressbar


Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2011, 06:42 PM
pollyar pollyar is offline
Newcomer
 
Join Date: Dec 2011
Posts: 4
Default Progressbar


Hello, I have a code with a progressbar to import data from text file. My problem is after first loop, a progressbar gets error. could anybody help me?

thanks,


Code:
Sub import_mgf()
Progressbar.Show vbModeless
Progressbar.Caption = "Process status"
Progressbar.ProgressBar1.Value = 1

Dim O_Fso As Object
Dim Txt_File As Object
Dim File_Path As String
Dim T_Str As String, Str_Ma4 As String
Dim T_Bool As Boolean
Dim Hld_Data As Variant
Dim Ma_H_Boo As Boolean
Dim Ctr As Long
Dim i As Long
Const LL_Cha As String = "CHARGE="
Const LL_End As String = "END IONS"
Const LL_Pep As String = "PEPMASS="
T_Bool = False
Ma_H_Boo = False
Ctr = 0
i = 1
File_Path = Application.GetOpenFilename( _
    FileFilter:="Mascot generic format (*.mgf), *.mgf, Comma Separated Files (*.csv), *.csv, All Files (*.*), *.*", _
    FilterIndex:=1, _
    Title:="Select a File")
    
If File_Path = "False" Then Exit Sub


Set O_Fso = CreateObject("Scripting.FileSystemObject")
Set Txt_File = O_Fso.OpenTextFile(File_Path)
With Txt_File
    Do Until .AtEndOfStream = True
        T_Str = .ReadLine
         
        If T_Str = LL_End Then
            T_Bool = False
            Ctr = 0
        End If
         
        If InStr(T_Str, LL_Pep) <> 0 Then Ma_H_Boo = True
         
        If Ma_H_Boo Then
            Hld_Data = Split(T_Str, Chr$(9))
            i = i + 1
            Cells(i, 1).Value = Replace(CStr(Hld_Data(0)), LL_Pep, "")
            Cells(i, 2).Value = 0
            Cells(i, 3).Value = 0
            i = i + 1
            Ma_H_Boo = False
        End If
         
        If T_Bool Then
            Ctr = Ctr + 1
            Hld_Data = Split(T_Str, Chr$(9))
             
            Cells(i, 1).Value = Hld_Data(0)
            Cells(i, 2).Value = Hld_Data(1)
            Cells(i, 3).Value = Hld_Data(2)
             
            If Ctr = 1 Then
                Cells(i - 1, 4).Value = Str_Ma4
            End If
            i = i + 1
                          
        End If
         
        If InStr(T_Str, LL_Cha) <> 0 Then
            T_Bool = True
            Hld_Data = Split(T_Str, "=")
            Str_Ma4 = CStr(Hld_Data(1))
            Str_Ma4 = Replace(Str_Ma4, "+", "")
        End If
          

Progressbar.ProgressBar1.Value = i

  Loop
     

    
End With
Txt_File.Close
Set Txt_File = Nothing
Set O_Fso = Nothing
 

Progressbar.Caption = "Ready"
Unload Progressbar

 Call clear_contents_ref02
 
End Sub
Reply With Quote
  #2  
Old 12-06-2011, 01:52 AM
Burningslash12's Avatar
Burningslash12 Burningslash12 is offline
Junior Contributor
 
Join Date: Sep 2008
Location: Singapore
Posts: 303
Default

Hi, what is the error you are seeing?
__________________
Burningslash12
"We may rise and fall, but in the end, we'll meet our fate together..."

Don't Click Me!
Reply With Quote
  #3  
Old 12-06-2011, 03:45 AM
TheRealTinTin's Avatar
TheRealTinTin TheRealTinTin is offline
Junior Contributor
 
Join Date: Nov 2008
Location: Glasgow, UK
Posts: 383
Default

Just scanned through the code quickly so this might not be your problem, but I don't see you setting the .Max of the ProgressBar anywhere - so are you perhaps reaching 100 (or whatever the Max is set to in the IDE) and then trying to go past that?
__________________
Artificial Intelligence is no match for natural stupidity
Reply With Quote
  #4  
Old 12-08-2011, 04:07 AM
Burningslash12's Avatar
Burningslash12 Burningslash12 is offline
Junior Contributor
 
Join Date: Sep 2008
Location: Singapore
Posts: 303
Default

This is also what i suspected. But somehow, i hoped that this is not the problem.
__________________
Burningslash12
"We may rise and fall, but in the end, we'll meet our fate together..."

Don't Click Me!
Reply With Quote
  #5  
Old 12-08-2011, 03:34 PM
DennisW's Avatar
DennisW DennisW is offline
Junior Contributor
 
Join Date: Mar 2006
Location: Östersund, Sweden
Posts: 268
Default

Hi,
The code in use seems to be VBA, right? So the post should be moved to Excel as this sub forum deals with .NET
__________________
Kind regards,
Dennis

.NET & Excel | 2nd edition PED | MVP
Reply With Quote
  #6  
Old 12-09-2011, 12:13 AM
TheRealTinTin's Avatar
TheRealTinTin TheRealTinTin is offline
Junior Contributor
 
Join Date: Nov 2008
Location: Glasgow, UK
Posts: 383
Default

Yes Dennis well spotted, the code appears to be VBA - suggested by this line: Application.GetOpenFilename.

Could one of the mods please move this over?
__________________
Artificial Intelligence is no match for natural stupidity
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Progressbar
Progressbar
Progressbar Progressbar
Progressbar
Progressbar
Progressbar Progressbar Progressbar Progressbar Progressbar Progressbar Progressbar
Progressbar
Progressbar
 
Progressbar
Progressbar
 
-->