Results 1 to 10 of 10

Thread: Loops Sort of....

  1. #1

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457

    Loops Sort of....

    Hey just me again with my slight problem

    I need a loop to do something like this

    word 0x00000000 ;material index Triangle 0
    word 0x00000000, 0x00000001, 0x00000002 ;vertex indices

    word 0x00000000 ;material index Triangle 1
    word 0x00000000, 0x00000002, 0x00000003 ;vertex indices

    word 0x00000000 ;material index Triangle 2
    word 0x00000004, 0x00000005, 0x00000006 ;vertex indices

    word 0x00000000 ;material index Triangle 3
    word 0x00000004 0x00000006, 0x00000007 ;vertex indices

    my code is this so far

    VB Code:
    1. Private Sub MakeTriangles()
    2. Dim Counter3 As Integer
    3. Dim Tri As Integer
    4. Dim TriNumber As Integer
    5. Tri = (txtFaces.Text * 2) 'Do Mathmatics
    6. Tri = (Tri - 1)
    7. TriangleNumber = 0
    8. For Counter3 = 0 To Tri ' Set up 10 repetitions.
    9. txtoutput.Text = txtoutput.Text & vbCrLf + "word    0x00000000                          ;material index       Triangle " & TriangleNumber
    10. txtoutput.Text = txtoutput.Text & vbCrLf + "word    0x00000000, 0x00000001, 0x00000002          ;vertex indices" & vbCrLf
    11. TriangleNumber = TriangleNumber + 1
    12. Next Counter3
    13. End Sub

    Which results in.....

    word 0x00000000 ;material index Triangle 0
    word 0x00000000, 0x00000001, 0x00000002 ;vertex indices

    word 0x00000000 ;material index Triangle 1
    word 0x00000000, 0x00000001, 0x00000002 ;vertex indices

    word 0x00000000 ;material index Triangle 2
    word 0x00000000, 0x00000001, 0x00000002 ;vertex indices

    word 0x00000000 ;material index Triangle 3
    word 0x00000000, 0x00000001, 0x00000002 ;vertex indices

    as you can see from the top segment of triangles

    but how can i go about implementing it so it does it this way

    so that it does the Values
    like in the top one
    so it can count up them

    i dont know how to make the first one only change after its done 2 of the same
    its hard to explain

    basicaly i need my program to replacate whats in the top lot

    we have got the formatting sorted so it can count in normal numbers

    then i can change it for when it prints the results

    as i say its hard to explain....
    www.azzmedia.co.uk

  2. #2
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350
    What line does the yellow bar lan on in debug?
    .

  3. #3

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    VB Code:
    1. Ahex = "0x" & String(8 - Len(Hex(Ahex)), "0") & Hex(A)
    www.azzmedia.co.uk

  4. #4

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    ??
    www.azzmedia.co.uk

  5. #5

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    Hmm
    Is it because i add something it dosent like the new numbers ?
    so it wont convert them ?
    hmm *Ponders*

    can you help
    www.azzmedia.co.uk

  6. #6
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    I think you're taking the wrong approach. What is the purpose if this code?
    You just proved that sig advertisements work.

  7. #7

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    The Code should work fine but its just that error
    it does what i have abouve it
    prints the triangle things and Should keep going but it dosent it goes through the thing once and on the second try it stops i just need to know why and how to fix it

    VB Code:
    1. Private Sub MakeTriangles()
    2. Tri = (txtFaces.Text * 1) 'Do Mathmatics
    3. Tri = (Tri - 1)
    4. TriangleNumber = 0
    5. Dim A As Integer
    6. Dim B As Integer
    7. Dim C As Integer
    8. Dim D As Integer
    9. Dim E As Integer
    10. Dim F As Integer
    11. A = 0
    12. B = 1
    13. C = 2
    14. D = 0
    15. E = 2
    16. F = 3
    17. For Counter3 = 0 To Tri
    18. Debug.Print Ahex
    19. Ahex = "0x" & String(8 - Len(Hex(Ahex)), "0") & Hex(A)
    20. Bhex = "0x" & String(8 - Len(Hex(Bhex)), "0") & Hex(B)
    21. Chex = "0x" & String(8 - Len(Hex(Chex)), "0") & Hex(C)
    22. Dhex = "0x" & String(8 - Len(Hex(Dhex)), "0") & Hex(D)
    23. Ehex = "0x" & String(8 - Len(Hex(Ehex)), "0") & Hex(E)
    24. Fhex = "0x" & String(8 - Len(Hex(Fhex)), "0") & Hex(F)
    25. txtoutput.Text = txtoutput.Text & vbCrLf + "    word    0x00000000                          ;material index       Triangle " & TriangleNumber
    26. txtoutput.Text = txtoutput.Text & vbCrLf + "    word    " & Ahex & ", " & Bhex & ", " & Chex & ", " & "          ;vertex indices" & vbCrLf
    27. TriangleNumber = TriangleNumber + 1
    28. txtoutput.Text = txtoutput.Text & vbCrLf + "    word    0x00000000                          ;material index       Triangle " & TriangleNumber
    29. txtoutput.Text = txtoutput.Text & vbCrLf + "    word    " & Dhex & ", " & Ehex & ", " & Fhex & ", " & "          ;vertex indices" & vbCrLf
    30. A = (A + 4)
    31. B = (B + 4)
    32. C = (C + 4)
    33. D = (D + 4)
    34. E = (E + 4)
    35. F = (F + 4)
    36. Next Counter3
    37. End Sub
    www.azzmedia.co.uk

  8. #8

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    Right still no Luck here i need your expertise hehe
    it does one loop then crashes on this line
    VB Code:
    1. Ahex = "0x" & String(8 - Len(Hex(Ahex)), "0") & Hex(A)

    It does it the first time around but the second run time error 13 type mismatch.........

    and i cant for the life of me see why
    www.azzmedia.co.uk

  9. #9

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    Bugger Bugger Bugger!
    i found the problem but now it just starts fresh every loop
    www.azzmedia.co.uk

  10. #10

    Thread Starter
    Hyperactive Member Azz00's Avatar
    Join Date
    Sep 2001
    Location
    Scotland
    Posts
    457
    Im so stupid
    it starts fresh because i put my clearing code over my Friggen loop code that adds numbers to the values each time!
    www.azzmedia.co.uk

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