Welcome to Dream.In.Code
Become a VB Expert!

Join 137,233 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,727 people online right now. Registration is fast and FREE... Join Now!




Changing Label Caption with Loops

 
Reply to this topicStart new topic

Changing Label Caption with Loops, need help

pau-pau
12 Feb, 2007 - 03:52 AM
Post #1

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 24


My Contributions
CODE

Private Sub Command2_Click()
Dim i
For i = 0 To 6
Label2(i).Caption = "i, k"
Next
End Sub


sorry for my question, I just can't find a sample right now

here is what i got,

I'm trying to display the value of "i" with the lettek "K" in the label's caption.

the output should look like this in the label:

0K 1k 2k 3k 4k 5k 6K

each one is on a different label

User is offlineProfile CardPM
+Quote Post

m2s87
RE: Changing Label Caption With Loops
12 Feb, 2007 - 05:51 AM
Post #2

D.I.C Regular
Group Icon

Joined: 28 Nov, 2006
Posts: 390



Thanked: 1 times
Dream Kudos: 1225
My Contributions
Try
QUOTE
Label2(i).Caption = i & "k"

User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Changing Label Caption With Loops
12 Feb, 2007 - 06:31 AM
Post #3

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,914



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
...or...
CODE
Label2(i).Caption = str(i) + "k"

User is offlineProfile CardPM
+Quote Post

pau-pau
RE: Changing Label Caption With Loops
13 Feb, 2007 - 12:52 AM
Post #4

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 24


My Contributions
@born2c0de
thanks

the code below is a continuation from the code in this topic
http://www.dreamincode.net/forums/showtopic23709.htm

CODE

Private Sub Command2_Click()
Dim i
Dim mem As Integer
Dim marker As Integer

mem = 0

Do While Not mem = 64
    For i = 1 To size
  
'memory size of job is <=4K
    If grid.TextMatrix(i, 3) <= 4 And marker = 0 Then
        Label2(6).Caption = "Job " & grid.TextMatrix(i, 0)
        marker = marker + 1
        mem = mem + 4
    'End If
    
    ElseIf grid.TextMatrix(i, 3) <= 4 And marker = 1 Then
        Label2(5).Caption = "Job " & grid.TextMatrix(i, 0)
        marker = marker + 1
        mem = mem + 4
    'End If
    
'memory size of job is <=8k
    ElseIf grid.TextMatrix(i, 3) <= 8 And marker = 2 Then
        Label2(4).Caption = "Job " & grid.TextMatrix(i, 0)
        marker = marker + 1
        mem = mem + 8
    'End If
    
    ElseIf grid.TextMatrix(i, 3) <= 8 And marker = 3 Then
        Label2(3).Caption = "Job " & grid.TextMatrix(i, 0)
        marker = marker + 1
        mem = mem + 8
    'End If
    
    If grid.TextMatrix(i, 3) <= 8 And marker = 4 Then
        Label2(2).Caption = "Job " & grid.TextMatrix(i, 0)
        marker = marker + 1
        mem = mem + 8
    End If

'memory size of job is <=16K
    ElseIf grid.TextMatrix(i, 3) <= 16 And marker = 5 Then
        Label2(1).Caption = "Job " & grid.TextMatrix(i, 0)
        marker = marker + 1
        mem = mem + 16
    'End If
    
    ElseIf grid.TextMatrix(i, 3) <= 16 And marker = 6 Then
        Label2(0).Caption = "Job " & grid.TextMatrix(i, 0)
        marker = marker + 1
        mem = mem + 16
    End If
    
    Next
Loop

End Sub


im having a hard time with my cpu algorithm's memory management..

i have to display the jobs to my memory(which i represented with labels) according to sizes; two 16k memory, three 8k, and two 4k. the jobs memory size range from 1K to 16K

the code displays the jobs but there are repititions and sometimes wrong memory size, i think the problem is with my arrays.....

can someone help me fix my code...

This post has been edited by pau-pau: 13 Feb, 2007 - 12:59 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:50PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month