Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » Classic Visual Basic (VB 6 or earlier) » General Visual Basic » Need Alittle Help Newbie Here


Need Alittle Help Newbie HereExpand / Collapse
Author
Message
Posted 2/26/2006 4:02:37 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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

Post #17132
Posted 2/26/2006 5:54:48 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum 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?

Post #17133
Posted 2/26/2006 6:52:19 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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

and so on

Post #17135
Posted 2/26/2006 9:50:35 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum 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.

Post #17138
Posted 2/26/2006 11:01:39 AM


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme 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
Post #17141
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 3:49am