🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#277
From: BKD
Date: Thu, 07 Dec 2000 00:00
108 lines
4272 bytes
Assuming the following declarations:

Dim strResValue As String, iFirstDigit As Integer, iSecondDigit As Integer,
iNumDigits as Integer

First, decode the slider:

    Select Case SRa.Value
        Case 3
            strResValue = 220
        Case 4
            strResValue = 270
        'add more cases as required
    End Select

Then get the first and second digits:

    iFirstDigit = Cint(Left$(strResValue,1)
    iSecondDigit = Cint(Mid$(strResValue,2,1)

Next get the number of zeros needed:

    iNumDigits = Len(strResValue) -2

Now apply them to the shapes with code like this:

    Select Case iFirstDigit
        Case 0
            ShapeA.BackColor = &H0&
        Case 1
            ShapeA.BackColor = &H4080&
        'and so on
    End Select

You could make it more efficient with enums and such like that, but this is
the basic gist as I would approach it.  Note that if you use tight tolerance
or low value resistors you will need to accomodate the decimal point in the
decoding statements.  Also this code assumes all values are in ohms, not K
or M.

Good Luck.

Brian-



Lasse Madsen <Lasse.Madsen@Elektronik.dk> wrote in message
news:90oika$143u$1@news.cybercity.dk...
> 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
>
>
> How can i do this ???
> --
>
> -------------------------
> Electronics Student
> Lasse Madsen
> H�jrupsvej 52, 2.m.f.
> 9900 Frederikshavn
> Denmark
>
>
Technical Details
Message-ID: <8%RX5.1$lM.226@newsfeed.avtel.net>
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
X-Google-Thread: f94ee,561b660d9b913f3d
X-Google-Attributes: gidf94ee,public
X-Google-Thread: f51ba,561b660d9b913f3d
X-Google-Attributes: gidf51ba,public
X-Google-Thread: 10cf61,561b660d9b913f3d
X-Google-Attributes: gid10cf61,public
X-Google-Thread: f645d,561b660d9b913f3d
X-Google-Attributes: gidf645d,public
X-Google-Thread: 106fd2,561b660d9b913f3d
X-Google-Attributes: gid106fd2,public
X-Google-Thread: 111c14,561b660d9b913f3d
X-Google-Attributes: gid111c14,public
X-Google-Thread: 107824,561b660d9b913f3d
X-Google-Attributes: gid107824,public
X-Google-Thread: fb992,561b660d9b913f3d
X-Google-Attributes: gidfb992,public
From: "BKD" <no.spam@here.now>
Subject: Re: HELP ! ! ! simple Visual Basic code ???
Date: 2000/12/07
Message-ID: <8%RX5.1$lM.226@newsfeed.avtel.net>
X-Deja-AN: 702284784
References: <90oika$143u$1@news.cybercity.dk>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
X-Complaints-To: abuse@avtel.com
X-Trace: newsfeed.avtel.net 976219204 207.71.193.193 (Thu, 07 Dec 2000 12:00:04 PST)
Organization: None
X-MSMail-Priority: Normal
X-Received-Date: Thu, 07 Dec 2000 12:00:04 PST (newsfeed.avtel.net)
NNTP-Posting-Date: Thu, 07 Dec 2000 12:00:04 PST
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