Solved

Very simple problem but I am too stupid :(

Posted on 1998-09-05
3
146 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now