🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.basic.visual
Article #276

Re: HELP ! ! ! simple Visual Basic code ???

#276
From: Nj�l Fisketj�n
Date: Thu, 07 Dec 2000 00:00
78 lines
3783 bytes
On Thu, 7 Dec 2000 19:03:46 +0100, "Lasse Madsen"
<Lasse.Madsen@Elektronik.dk> wrote:

>Hi there im making a small resistor color code calculator based on a slider
>(SRa) and 4 (shapes a,b,c and d) the shapes is placed like this |a|b|c|d|
>after eatch other to symbolise a resistor. what i want is:
>
>make my slider code control the colors of the 4 shapes (a,b,c,d,)
>Below is the colour code a resistor can have and which the 4 shapes should
>be assigned
>
>Black = &H0&
>Brown = &H4080&
>Red = &HFF&
>Orange = &H80FF&
>Yellow = &HFFFF&
>Green = &HC000&
>Blue = &HFF0000
>Purple = &HC000C0
>Gray = &H808080
>White = &HFFFFFF
>
>Below you see what each colour represents in decimal values
>Black = 0
>Brown = 1
>Red = 2
>Orange 3
>Yellow = 4
>Green =  5
>Blue =  6
>Purple =7
>Gray =8
>White ==9
>
>A resistor value is determined like this:
>220 Ohms = 2 - 2 - 0 (first and second digit and third value) but when
>converted to color code its like this
>2 - 2 - 0 =
>Red - Red (2 - 2)
>the 0 determins how many zeros that is after the 2 digits (in this case 2-2)
>and the color code will be RED - RED - BROWN (brown because because you need
>1 zero after 2-2 to make 220 !)
>
>If SRa.Value = 3 Then TRa.Text = "220" & " ohms"    / this should be 2-2-1
>Red-Red-Black
>If SRa.Value = 4 Then TRa.Text = "270" & " ohms"   /this should be 2-7-1
>Red-Purple-Brown
>

I don't understand the concept of changing the ending 0 to 1, but apart
from that here's some code that might help:

I've put a slider on my form together with 4 shapes, and I've set the
FillStyle property of the shapes to Solid.

Private Sub Slider1_Change()
  Dim i As Integer
  Dim ColorCode As Variant
  Dim cc(9) As Long
  Dim strValue As String
  
  i = 0
  For Each ColorCode In Array(&H0&, &H4080&, &HFF&, &H80FF&, &HFFFF&,
    &HC000&, &HFF0000, &HC000C0, &H808080, &HFFFFFF)
    cc(i) = ColorCode
    i = i + 1
  Next
  
  strValue = Trim$(Str$(Slider1.Value))
  For i = 0 To Len(strValue) - 1
    If i > Shape1.UBound Then Exit For
    Shape1(i).FillColor = cc(Val(Mid$(strValue, i + 1, 1)))
    Shape1(i).Visible = True
  Next
  For i = Len(strValue) To Shape1.UBound
    Shape1(i).Visible = False
  Next
End Sub
Technical Details
Message-ID: <nopv2tg3toqp50ij2rsk4cn8rrhvr3k9sb@4ax.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <90oika$143u$1@news.cybercity.dk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f94ee,561b660d9b913f3d,start
X-Google-Attributes: gidf94ee,public
X-Google-Thread: f645d,561b660d9b913f3d,start
X-Google-Attributes: gidf645d,public
X-Google-Thread: 10cf61,561b660d9b913f3d,start
X-Google-Attributes: gid10cf61,public
X-Google-Thread: 111c14,561b660d9b913f3d,start
X-Google-Attributes: gid111c14,public
X-Google-Thread: 106fd2,561b660d9b913f3d,start
X-Google-Attributes: gid106fd2,public
X-Google-Thread: fb992,561b660d9b913f3d,start
X-Google-Attributes: gidfb992,public
X-Google-Thread: f51ba,561b660d9b913f3d,start
X-Google-Attributes: gidf51ba,public
X-Google-Thread: 107824,561b660d9b913f3d,start
X-Google-Attributes: gid107824,public
From: Nj�l Fisketj�n <n.f@figu.no>
Subject: Re: HELP ! ! ! simple Visual Basic code ???
Date: 2000/12/07
Message-ID: <nopv2tg3toqp50ij2rsk4cn8rrhvr3k9sb@4ax.com>
X-Deja-AN: 702279041
Content-Transfer-Encoding: 7bit
References: <90oika$143u$1@news.cybercity.dk>
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@powertech.no
X-Trace: troll.powertech.no 976218157 6178 195.159.44.160 (7 Dec 2000 19:42:37 GMT)
Organization: PowerTech, +47-2220-3330
Mime-Version: 1.0
NNTP-Posting-Date: 7 Dec 2000 19:42:37 GMT
Newsgroups: comp.lang.basic.visual,comp.lang.visual.basic,dk.edb.programmering.basic.visual-basic,fj.comp.lang.visualbasic,free.it.programmazione.visualbasic,free.it.visual-basic,microsoft.private.mvp.VisualBasic,no.it.programmering.visual-basic