![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jun 2008
Posts: 6
OS: WindowsXP
|
I like to try figuring how to shorten code before I resort to the last possibility, but I have had trouble with this one. Any insight into to shortening this would be appreciated :
Private Sub Timer1_Timer() If VScroll1.Value = 0 Then MSComm1.Output = "VOL00 " & Chr$(13) ElseIf VScroll1.Value = 1 Then MSComm1.Output = "VOL01 " & Chr$(13) ElseIf VScroll1.Value = 2 Then MSComm1.Output = "VOL02 " & Chr$(13) ElseIf VScroll1.Value = 3 Then MSComm1.Output = "VOL03 " & Chr$(13) ElseIf VScroll1.Value = 4 Then MSComm1.Output = "VOL04 " & Chr$(13) ElseIf VScroll1.Value = 5 Then MSComm1.Output = "VOL05 " & Chr$(13) ElseIf VScroll1.Value = 6 Then MSComm1.Output = "VOL06 " & Chr$(13) ElseIf VScroll1.Value = 7 Then MSComm1.Output = "VOL07 " & Chr$(13) ElseIf VScroll1.Value = 8 Then MSComm1.Output = "VOL08 " & Chr$(13) ElseIf VScroll1.Value = 9 Then MSComm1.Output = "VOL09 " & Chr$(13) ElseIf VScroll1.Value = 10 Then MSComm1.Output = "VOL10 " & Chr$(13) ElseIf VScroll1.Value = 11 Then MSComm1.Output = "VOL11 " & Chr$(13) ElseIf VScroll1.Value = 12 Then MSComm1.Output = "VOL12 " & Chr$(13) ElseIf VScroll1.Value = 13 Then MSComm1.Output = "VOL13 " & Chr$(13) ElseIf VScroll1.Value = 14 Then MSComm1.Output = "VOL14 " & Chr$(13) ElseIf VScroll1.Value = 15 Then MSComm1.Output = "VOL15 " & Chr$(13) ElseIf VScroll1.Value = 16 Then MSComm1.Output = "VOL16 " & Chr$(13) ElseIf VScroll1.Value = 17 Then MSComm1.Output = "VOL17 " & Chr$(13) ElseIf VScroll1.Value = 18 Then MSComm1.Output = "VOL18 " & Chr$(13) ElseIf VScroll1.Value = 19 Then MSComm1.Output = "VOL19 " & Chr$(13) ElseIf VScroll1.Value = 20 Then MSComm1.Output = "VOL20 " & Chr$(13) ElseIf VScroll1.Value = 21 Then MSComm1.Output = "VOL21 " & Chr$(13) ElseIf VScroll1.Value = 22 Then MSComm1.Output = "VOL22 " & Chr$(13) ElseIf VScroll1.Value = 23 Then MSComm1.Output = "VOL23 " & Chr$(13) ElseIf VScroll1.Value = 24 Then MSComm1.Output = "VOL24 " & Chr$(13) ElseIf VScroll1.Value = 25 Then MSComm1.Output = "VOL25 " & Chr$(13) ElseIf VScroll1.Value = 26 Then MSComm1.Output = "VOL26 " & Chr$(13) ElseIf VScroll1.Value = 27 Then MSComm1.Output = "VOL27 " & Chr$(13) ElseIf VScroll1.Value = 28 Then MSComm1.Output = "VOL28 " & Chr$(13) ElseIf VScroll1.Value = 29 Then MSComm1.Output = "VOL29 " & Chr$(13) ElseIf VScroll1.Value = 30 Then MSComm1.Output = "VOL30 " & Chr$(13) Thanks |
|
|
|
|
|
#2 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Northampton, UK
Posts: 937
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)
|
Re: Shorting code question
Try:
Code:
MSComm1.Output = "VOL" & VScroll.Value & " " & Chr$(13) Actually you will have to parse the VScroll.Value property if the number is <10 so maybe something like: Code:
If VScroll1.Value < 10 Then MSComm1.Output = "VOL0" & VScroll.Value & " " & Chr$(13) Else MSComm1.Output = "VOL" & VScroll.Value & " " & Chr$(13) Cheers, Jamey Last edited by jamiemac2005 : 07-08-2008 at 04:47 PM. Reason: Missing code endtag |
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: Jun 2008
Posts: 6
OS: WindowsXP
|
Re: Shorting code question
Thanks, I have tried something like that....I dimmed a text and tried &'d, but it doesn't seem to work. I got it to work the long way, but I will try figuring it out a shorter way. Otherwise, I will just keep it how I got it. It seems to work well inside a timer with about a sec duration between the values. Thanks
|
|
|
|
![]() |
| Thread Tools | |
|
|