Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 21st, 2006, 08:54 AM
Phoenix_riser Phoenix_riser is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 225 Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 2 h 28 m 15 sec
Reputation Power: 15
Delete labels etc...

If this...

Code:
                                If lngRecordCount3 <> 0 Then
                                    For Index = 0 To lngRecordCount3
                                    Load lblName(Index)
                                    lblName(Index).Left = vPlace + 100
                                    lblName(Index).Top = vTop + 100
                                    llblName(Index).Visible = True
                                    Next
                                End If


creates labels how to I delete them later?

If I create 10 and next time I only want say 8 then I'd not want then last 2.

Tried Kill lblName(0) but this did not work :-(

Reply With Quote
  #2  
Old February 21st, 2006, 09:06 AM
D.O.M.I.N.A.T.O.R's Avatar
D.O.M.I.N.A.T.O.R D.O.M.I.N.A.T.O.R is offline
Kingpin contributor
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Nov 2005
Location: P.E, RSA
Posts: 1,051 D.O.M.I.N.A.T.O.R User rank is First Lieutenant (10000 - 20000 Reputation Level)D.O.M.I.N.A.T.O.R User rank is First Lieutenant (10000 - 20000 Reputation Level)D.O.M.I.N.A.T.O.R User rank is First Lieutenant (10000 - 20000 Reputation Level)D.O.M.I.N.A.T.O.R User rank is First Lieutenant (10000 - 20000 Reputation Level)D.O.M.I.N.A.T.O.R User rank is First Lieutenant (10000 - 20000 Reputation Level)D.O.M.I.N.A.T.O.R User rank is First Lieutenant (10000 - 20000 Reputation Level)D.O.M.I.N.A.T.O.R User rank is First Lieutenant (10000 - 20000 Reputation Level)D.O.M.I.N.A.T.O.R User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 2 h 12 m 16 sec
Reputation Power: 201
Quote:
Originally Posted by Phoenix_riser
If this...

Code:
                                If lngRecordCount3 <> 0 Then
                                    For Index = 0 To lngRecordCount3
                                    Load lblName(Index)
                                    lblName(Index).Left = vPlace + 100
                                    lblName(Index).Top = vTop + 100
                                    llblName(Index).Visible = True
                                    Next
                                End If


creates labels how to I delete them later?

If I create 10 and next time I only want say 8 then I'd not want then last 2.

Tried Kill lblName(0) but this did not work :-(


Not so sure, but how about setting the instance of the label to be nothing, much like:

lblName(Index) = nothing

Give it a try!
J.
__________________
Fitness & Diet resources Career Descriptions Boat Cruises
All code that is posted by me has not been tested, and it should only be interpreted as a guideline to a solution. There is no guarantee that any of my code samples will work as provided, and should be customized to suite the required need.

Reply With Quote
  #3  
Old February 21st, 2006, 09:16 AM
Phoenix_riser Phoenix_riser is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 225 Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 2 h 28 m 15 sec
Reputation Power: 15
Quote:
Originally Posted by D.O.M.I.N.A.T.O.R
Not so sure, but how about setting the instance of the label to be nothing, much like:

lblName(Index) = nothing

Give it a try!
J.


Fraid not, tried Null as well, 0 just makes it show 0 too.
Also tried cancel

Reply With Quote
  #4  
Old February 21st, 2006, 11:38 AM
LozWare's Avatar
LozWare LozWare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2005
Posts: 531 LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 10 h 56 m 31 sec
Reputation Power: 46
Send a message via MSN to LozWare
lol - this is where i come in...VB is my thing!

Code:
Unload lblName(Index)


But remember... you cannot unload objedcts that are created at design time, you can only 'delete' objects that you create yourself using code.
__________________
LozWare Website Directory

Whooo! Free submissions, no recip needed. I'm a nice guy

Reply With Quote
  #5  
Old February 22nd, 2006, 05:07 AM
Phoenix_riser Phoenix_riser is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 225 Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 2 h 28 m 15 sec
Reputation Power: 15
Perfect thank you..

Load lbl1

lbl1.Caption = "test"
lbl1 = vPlace + 10000
lbl1Top = vTop + 1000
lbl1.Visible = True

Unload lbl1

Reply With Quote
  #6  
Old February 22nd, 2006, 09:09 AM
LozWare's Avatar
LozWare LozWare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2005
Posts: 531 LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 10 h 56 m 31 sec
Reputation Power: 46
Send a message via MSN to LozWare
No prob - mind giving us a rep point? I only have 2 :-/
Comments on this post
Phoenix_riser agrees: Nice one :-)

Reply With Quote
  #7  
Old February 23rd, 2006, 05:52 AM
Phoenix_riser Phoenix_riser is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 225 Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 2 h 28 m 15 sec
Reputation Power: 15
See if you fancy a big more a of a problem on the same lines. When I try to run the code now with the;
Code:

                                If lngRecordCount3 > 0 Then
                                    For Index = 0 To lngRecordCount3
                                    Load lblName(Index)
                                    lblName(Index).Caption = "1"
                                    lblName(Index).Left = vPlace + 100
                                    lblName(Index).Top = vTop + 100
                                    lblName(Index).Visible = True
                                    Next
                                End If

it gives me a "Sub or Function" not defined error. Any ideas?
The idea behind this was to create a graph on the fly, this part is the labels then I would repeat but for a line (on it's side)


Hope you're as sharp and quick as yesterday!

Code:

Private Sub cmdStatistics_Click()

Dim db1 As Database
'
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset
'
Dim lngRecordCount1 As Long
Dim lngRecordCount2 As Long
Dim lngRecordCount3 As Long
'
'Dim Percent As Curreny
'
Set db1 = DBEngine.OpenDatabase("\\server2\prog\Christmas Lights\Contacts\DBconsumers.mdb")
'

''Select distint by type and then roll through checking if a person has that type, if so add to lngRecordCount x,y,z
strSQL3 = "SELECT DISTINCT type FROM TBconsumers"
strSQL2 = "select Type FROM TBconsumers"
'
Set rs2 = db1.OpenRecordset(strSQL2)
Set rs3 = db1.OpenRecordset(strSQL3)
'
rs3.MoveLast
lngRecordCount3 = rs3.RecordCount
rs3.MoveFirst
'
For Counter = 1 To lngRecordCount3 'count unique types of customer and set up labels for them with the graph

rs3.Fields("type") = vType

                                If lngRecordCount3 > 0 Then
                                    For Index = 0 To lngRecordCount3
                                    Load lblName(Index)
                                    lblName(Index).Caption = "1"
                                    lblName(Index).Left = vPlace + 100
                                    lblName(Index).Top = vTop + 100
                                    lblName(Index).Visible = True
                                    Next
                                End If


                          strSQL2 = "SELECT * FROM TBconsumers WHERE type = '" & vType & "'"
                                Set rs2 = db1.OpenRecordset(strSQL2)
                                If rs2.RecordCount > 0 Then
                                    rs2.MoveLast
                                    lngRecordCount2 = rs2.RecordCount
                                    rs2.MoveFirst
                                Else
                                    lngRecordCount2 = 0
                                End If
                                '
                                For Index = Counter To Counter
                                lblName(Index) = lngRecordCount2
                                End If
                                
                                
                                rs3.MoveNext
                                Form1.Caption = lngRecordCount1 - Counter
                                rs2.Close
                            Next
                            '
                            
                                            If lngRecordCount3 > 0 Then
                                            For Index = 0 To lngRecordCount3
                                            lblName(Index).Refresh
                                            Next
                                            End If
                                    
                                    
                            rs3.Close
                            db1.Close
                            '
                            MsgBox "Done"
                            
    End Sub 

Reply With Quote
  #8  
Old February 23rd, 2006, 08:38 AM
LozWare's Avatar
LozWare LozWare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2005
Posts: 531 LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 10 h 56 m 31 sec
Reputation Power: 46
Send a message via MSN to LozWare
At what exact line does the error display on? VB6 will show you (it high-lights it in yellow).

EDIT:
I take it that vTop and vPlace are global variables, right?

Reply With Quote
  #9  
Old February 27th, 2006, 04:04 AM
Phoenix_riser Phoenix_riser is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 225 Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 2 h 28 m 15 sec
Reputation Power: 15
Found the problem..

You must have the first instance already in existance from what I can tell. e.g. Command7 already existed as Command7(0)

Here is the code so far - you will note at the bottom the way to add graphics, not stunning but works. Next stage to push to a html file when I get sometime!

Code:
Private Sub cmdStatistics_Click()

Dim db1 As Database
'
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset
'
Dim lngRecordCount1 As Long
Dim lngRecordCount2 As Long
Dim lngRecordCount3 As Long
'
Dim Index As Long
'Dim Percent As Curreny
'
vUnload = 0
Set db1 = DBEngine.OpenDatabase("\\server2\prog\Christmas Lights\Contacts\DBconsumers.mdb")
'

''Select distint by type and then roll through checking if a person has that type, if so add to lngRecordCount x,y,z
strSQL3 = "SELECT DISTINCT type FROM TBconsumers"
'strSQL2 = "select Type FROM TBconsumers"


Set rs3 = db1.OpenRecordset(strSQL3)
'
rs3.MoveLast
lngRecordCount3 = rs3.RecordCount
rs3.MoveFirst
'
For Counter = 1 To lngRecordCount3 'count unique types of customer and set up labels for them with the graph

On Error GoTo ErrorHandler340

                            If vUnload = 0 Then
                            For Index = 1 To 99 ' cmdlabels
                            Unload Command7(Index)
                            Next
                            Else
                            End If
        vUnload = 1
        

                                
vType = rs3.Fields("type")

                          strSQL2 = "SELECT Type FROM TBconsumers WHERE type = '" & vType & "'"
                                Set rs2 = db1.OpenRecordset(strSQL2)
                                If rs2.RecordCount > 0 Then
                                    rs2.MoveLast
                                    lngRecordCount2 = rs2.RecordCount
                                    rs2.MoveFirst
                                Else
                                    lngRecordCount2 = 0
                                End If





                                If lngRecordCount3 = lngRecordCount3 Then
                                If lngRecordCount3 > 0 Then
                                    For Index = Counter To Counter
                                    vTop = vTop + 200
                                    Load Command7(Index)
                                    Command7(Index).Caption = Index
                                    Command7(Index).Caption = rs3.Fields("type")
                                    Command7(Index).Left = vPlace + 575
                                    Command7(Index).Top = vTop
                                    Command7(Index).Width = 2000
                                    Command7(Index).Height = 100
                                    Command7(Index).Visible = True
                                    Next
                                                                    Else
                                End If

                                End If











                                rs3.MoveNext
                                Form1.Caption = lngRecordCount1 - Counter
                                rs2.Close
 Next
                        
                            '
                                                  If lngRecordCount3 > 0 Then
                                                                For Index = 0 To lngRecordCount3
                                                                Command7(Index).Refresh
                                                                Next
                                                                End If
                                                        
                                            
                            
                            rs3.Close
                            db1.Close
                            '
                            MsgBox "Done"
                            
                            
ErrorHandler340:
    If Err.Number = 340 Then
                Resume Next
    Else
        Refresh
    End If
                            
    End Sub
    
'Need to add in percents as well in a line system
'Percent = lngRecordCount1 / lngRecordCount2
'Percent = Percent * 100
'Line1.BorderWidth = Percent
'Line1.BorderColor = 16711680
'Label1.Caption = Format(Percent, "### 0.00")
'Label2.Caption = lngRecordCount1
'Line1.Refresh

Reply With Quote
  #10  
Old March 6th, 2006, 10:18 AM
Nabi Bux Nabi Bux is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 18 Nabi Bux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 9 m 4 sec
Reputation Power: 0
Good reply

first all keepnin mind contrl created design time canotbe
unload
creat label at run time
then you can unload them

Reply With Quote
  #11  
Old March 7th, 2006, 04:37 AM
Phoenix_riser Phoenix_riser is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 225 Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level)Phoenix_riser User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 2 h 28 m 15 sec
Reputation Power: 15
One working model...

Code:

Private Sub cmdStatistics_Click()
'
Dim db1 As Database
'
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset
'
Dim lngRecordCount1 As Long
Dim lngRecordCount2 As Long
Dim lngRecordCount3 As Long
'
Dim Index As Long
'
vTop = vTop + 600
vUnload = 0
Set db1 = DBEngine.OpenDatabase("DBconsumers.mdb")
'
Form1.Caption = "Processing"
'
'Select distint by type and then roll through checking if a person has that type, if so add to lngRecordCount x,y,z
strSQL3 = "SELECT DISTINCT type FROM TBconsumers"
'
Set rs3 = db1.OpenRecordset(strSQL3)
'
rs3.MoveLast
lngRecordCount3 = rs3.RecordCount
rs3.MoveFirst
'
strSQL1 = "SELECT Orderid FROM TBconsumers"
'
Set rs1 = db1.OpenRecordset(strSQL1)
'
rs1.MoveLast
lngRecordCount1 = rs1.RecordCount
rs1.MoveFirst
'
For Counter = 1 To lngRecordCount3 'count unique types of customer and set up labels for them with the graph
'
On Error GoTo ErrorHandler340
                                    ''''''''''''''''''''''''''''''''''''
                            If vUnload = 0 Then
                            For Index = 1 To 99
                            Unload Command7(Index)
                            Unload Line1(Index)
                            Unload Command8(Index)
                            Next
                            Else
                            End If
        vUnload = 1
                                    ''''''''''''''''''''''''''''''''''''
                          strSQL2 = "SELECT Type FROM TBconsumers WHERE type = '" & rs3.Fields("type") & "'"
                                Set rs2 = db1.OpenRecordset(strSQL2)
                                If rs2.RecordCount > 0 Then
                                    rs2.MoveLast
                                    lngRecordCount2 = rs2.RecordCount
                                    rs2.MoveFirst
                                Else
                                    lngRecordCount2 = 0
                                End If
                                    ''''''''''''''''''''''''''''''''''''
                                If lngRecordCount3 = lngRecordCount3 Then
                                If lngRecordCount3 > 0 Then
                                    For Index = Counter To Counter ' creates a loop
                                    vTop = vTop + 300
                                    vPlace1 = 4750
                                    Load Command7(Index)
                                    Command7(Index).Caption = Index
                                    Command7(Index).Caption = rs3.Fields("type")
                                    Command7(Index).Left = vPlace + 500
                                    Command7(Index).Top = vTop
                                    Command7(Index).Width = 2000
                                    Command7(Index).Height = 100
                                    Command7(Index).Visible = True
                                    ''''''''''''''''''''''''''''''''''''
                                    'Need to add in percents as well in a line system
                                    Percent = lngRecordCount2 / lngRecordCount1
                                    Percent = Percent * 100
                                    'Line1(Index).Refresh
                                    ''''''''''''''''''''''''''''''''''''
                                    Load Line1(Index)
                                    'Line1(Index) = Index
                                    Line1(Index).Y1 = vTop + 100
                                    Line1(Index).Y2 = vTop + 100
                                    Line1(Index).X1 = vPlace1
                                    Line1(Index).X2 = vPlace1 + (Percent * 100)
                                    Line1(Index).Visible = True
                                    '
                                    Load Command8(Index)
                                    Command8(Index).Caption = Index
                                    Command8(Index).Left = vPlace + 2650
                                    Command8(Index).Top = vTop
                                    Command8(Index).Width = 2000
                                    Command8(Index).Height = 100
                                    Command8(Index).Visible = True
                                    Command8(Index).Caption = Format(Percent, "### 0.00")
                                    ''''''''''''''''''''''''''''''''''''
                                    Next
                                                                    Else
                                End If
                                End If
'
                                rs3.MoveNext
                                Form1.Caption = lngRecordCount1 - Counter
                                rs2.Close
 Next
        If Form1.BackColor = &HFFC0C0 Then
        MsgBox "Statistics redone"
        Else
        Form1.BackColor = &HFFC0C0
        End If
        Form1.Height = 1000 + vTop
'reset all the values and refresh
                                                  If lngRecordCount3 > 0 Then
                                                                For Index = 0 To lngRecordCount3
                                                                Command7(Index).Refresh
                                                                Next
                                                                End If
Form1.Caption = "Statistics V1.0 - Statistics run"
cmdStatistics.BackColor = &HFF8080

Exit Sub
ErrorHandler340:
    If Err.Number = 340 Then
                Resume Next
    Else
        Refresh
    End If
'
    End Sub 

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Delete labels etc...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump