|
-
Jul 20th, 2004, 01:33 PM
#1
Thread Starter
Hyperactive Member
Why am I getting a type mismatch here!? [resolved]
I'm using this code to display a random advert in a form (either ad1.bmp, ad2.bmp or ad3.bmp) but it keeps failing with a compile error - type mismatch at the last & sign in the code.
Any ideas why?
Simon
Code:
Private Function RandomInteger(Lowerbound As Integer, Upperbound As Integer) As Integer
RandomInteger = Int((Upperbound - Lowerbound + 1) * Rnd + Lowerbound)
End Function
Code:
Randomize
picAdvert.Picture = (App.Path & "/ad" & RandomInteger(1, 3) & ".bmp")
Last edited by simonp; Jul 20th, 2004 at 02:20 PM.
-
Jul 20th, 2004, 01:38 PM
#2
which line was the error on?
-
Jul 20th, 2004, 01:39 PM
#3
Thread Starter
Hyperactive Member
picAdvert.Picture = (App.Path & "/ad" & RandomInteger(1, 3) & ".bmp")
there!
-
Jul 20th, 2004, 01:53 PM
#4
One thing that is wrong is
picAdvert.Picture = (App.Path & "\ad" & RandomInteger(1, 3) & ".bmp")
-
Jul 20th, 2004, 01:55 PM
#5
would that solve the mismatch?
-
Jul 20th, 2004, 01:56 PM
#6
Thread Starter
Hyperactive Member
Thanks Martin - same problem with the mismatch though 
I can get the random number ok - just doesn't seem to like it in that line 
Simon
-
Jul 20th, 2004, 01:58 PM
#7
maybe you should do this...
VB Code:
dim number as long
number = randominteger(1,3)
picAdvert.Picture = (App.Path & "\ad" & number & ".bmp")
-
Jul 20th, 2004, 02:00 PM
#8
Thread Starter
Hyperactive Member
type mismatch in exactly the same place!
How bizarre?!
Simon
-
Jul 20th, 2004, 02:01 PM
#9
at the point before oppening the app whats the value of the random number?
-
Jul 20th, 2004, 02:01 PM
#10
Oh, I know what the problem is - remove the parentheses.
-
Jul 20th, 2004, 02:03 PM
#11
Thread Starter
Hyperactive Member
Same problem Martin (tried that before).
Pino - not sure what you mean there - the random number part works fine (tested with a msgbox)
SImon
-
Jul 20th, 2004, 02:04 PM
#12
Thread Starter
Hyperactive Member
Incidently, this works fine:
Code:
MsgBox App.Path & "\ad" & RandomInteger(1, 3) & ".bmp"
-
Jul 20th, 2004, 02:05 PM
#13
Put together a small project that demonstrates the problem, zip it up and post it. Please make sure to include the bmps.
-
Jul 20th, 2004, 02:10 PM
#14
Thread Starter
Hyperactive Member
wow - this is driving me crazy!
Here you go folks.
Simon
(attachment deleted - resolved)
Last edited by simonp; Jul 20th, 2004 at 02:21 PM.
-
Jul 20th, 2004, 02:18 PM
#15
done...
VB Code:
picAdvert.Picture = LoadPicture(App.Path & "/ad" & RandomInteger(1, 3) & ".bmp")
-
Jul 20th, 2004, 02:20 PM
#16
Thread Starter
Hyperactive Member
oh what a fool 
I can't believe I missed that!
Thanks pino
Simon
-
Jul 20th, 2004, 02:21 PM
#17
-
Jul 20th, 2004, 02:22 PM
#18
Thread Starter
Hyperactive Member
already done
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|