Solved

Very simple problem but I am too stupid :(

Posted on 1998-09-05
3
152 Views
Last Modified: 2010-04-30
******************************************
Declerations:
DIM Screen(20) as String

Private Sub Command1_Click()
For H = 1 To Picture1.Height - 15 Step 15
For W = 1 To Picture1.Width - 15 Step 15
Colorvalue$ = Right$("0000" + Hex$((Picture1.Point(W, H))), 6)
Blue = Val("&H" + Mid$(Colorvalue$, 1, 2))
L$ = L$ + Chr$(blau)
Next
Command2.Caption = Int((H / Picture1.Height) * 100) + "%"
Next
Screen(1) = "Hallo"
End Sub
***************
Why I get "Laufzeitfehler 13 - Typen unverträglich!" ???
0
Comment
Question by:Okano
3 Comments
 
LVL 12

Accepted Solution

by:
mark2150 earned 50 total points
ID: 1433219
Blue = Val("&H" + Mid$(Colorvalue$, 1, 2))
    L$ = L$ + Chr$(blau)

The VAL statement cannot accept "&Hxxxx" as an arguement so BLUE is forever returning zero. CHR$() will generate an error when passed a zero.

I see it looks like you're trying to convert a hex string color value back into a numeric. Your approach will not work. Try:

MSN$ = ucase$( mid$( colorvalue$, 1, 1) )  ' Get MS digit
LSN$ = ucase$( mid$( colorvalue$, 2, 1) )  'Get LS digit
hx = "123456789ABCDEF" 'Position in string corresponds to hex value, zero not used
value = instr( hx$, msn$ ) * 16 + instr( hx$, lsn$ )   'Value will have decimal equiv of hex


0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1433220

Command2.Caption = Int((H / Picture1.Height) * 100) & "%"

Not  100) + "%"

Give points to  mark2150 if answer is accepted
0
 

Expert Comment

by:dbardi
ID: 1433221
Both '+' and '&' will work.
The norm is to use '&' to avoid confusion with numeric calculations.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question