| | | Forum Newbie
       
Group: Forum Members Last Login: 5/13/2006 11:49:01 AM Posts: 9, Visits: 38 |
| | Hi Still trying to get to grips with VB proving alittle more difficult than expected but not to worry (i hope) im not sure if any of may be able to help me but could you please explain why this code does do what its supposed to? Private Sub MultiCol_Click() Dim text As String Dim i As Integer text = Text1.text text = Left(text, 1) text = Right(text, 1) text = Mid(text, 1) For i = 0 To Len(text) text = text & "#c?#" & text Next sendmx text, List1.List(List1.ListIndex) Text1.text = "" End Sub what it is supposed to do is send multi colours for each letter like EG : R B P and so on for a hole phrase but it only seems to say and repeat the first letter i put in my text box so if anyone can help it is grealty thanked |
| | | | Forum Member
       
Group: Forum Members Last Login: 12/13/2006 8:33:08 AM Posts: 72, Visits: 60 |
| | Your code is doing exactly what you told it to do. By the time it gets to your For loop, there is only 1 character to assign a color to. Here is the offending code: text = Text1.text text = Left(text, 1) 'there is only 1 character from this point forward text = Right(text, 1) text = Mid(text, 1) What exactly is that code supposed to do anyway? |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 5/13/2006 11:49:01 AM Posts: 9, Visits: 38 |
| | You heard of a P2P program called WinMx well i got a chat room in there and it does colour so i want it to display a colour for each letter like a b c d and so on
|
| | | | Forum Member
       
Group: Forum Members Last Login: 10/16/2009 10:14:44 AM Posts: 38, Visits: 45 |
| | Your "text" variable is ovewriting itself which is why you only have one character in there. Your best bet is to store the text in an array and iterate through the array in your For loop setting the color of each character with each iteration. |
| | | | 
Supreme Being
       
Group: Forum Members Last Login: 3/2/2008 7:07:37 PM Posts: 272, Visits: 602 |
| | I think you are trying to do something like this... Dim strText As String Dim i As Integer 'text = Text1.text 'text = Left(text, 1) 'text = Right(text, 1) For i = 1 To Len(Text1.text) strText = strText & Mid(Text1.text, i, 1) & "#c?#" Next Text2.text = strText
KlinerDraken http://new.kd-radio.com |
| |
|
|