Extremely N00b VB query

Get help on programming - C++, Java, Delphi, etc.
Post Reply
DJT
I Bribed Ron With Foundry And All I Got Was This Lousy Title
Posts: 9387
Joined: 09 Aug 2002, 02:00
Location: Locked Down
Contact:

Extremely N00b VB query

Post by DJT »

Ok, I haven't done VB in ages and it shows.
I am making a prog that will generate numbers and then depending on what that number is, show a word. I'm not going to say what the prog is just yet, but I need help

Don't flame me for stupidity, I aint a programmer

Code: Select all

Private Sub Command1_Click()
lblC1.Caption = Int(Rnd * 54)
lblC2.Caption = Int(Rnd * 54)
lblC3.Caption = Int(Rnd * 5)

If lblC1.Caption = 0 Then
lbl1.Caption = "Temporary"

End Sub
I get a compile error. Block if without End if

Someone care to show me what a noob I am being and fix it please?
Want to support my creative work? Drop me a like and subscribe below. It will be greatly appreciated!
Clarke Media - YouTube Channel
Clarke Media - Facebook
DJT
I Bribed Ron With Foundry And All I Got Was This Lousy Title
Posts: 9387
Joined: 09 Aug 2002, 02:00
Location: Locked Down
Contact:

Post by DJT »

Ah FFS!

Found it, I tried adding End If to the end, but didn't like it, so i stuck it underneath and it works.

Thanks anyways
Want to support my creative work? Drop me a like and subscribe below. It will be greatly appreciated!
Clarke Media - YouTube Channel
Clarke Media - Facebook
Hex_Rated
Registered User
Posts: 3679
Joined: 19 Jan 2006, 02:00
Contact:

Post by Hex_Rated »

Code: Select all

Private Sub Command1_Click()
lblC1.Caption = Int(Rnd * 54)
lblC2.Caption = Int(Rnd * 54)
lblC3.Caption = Int(Rnd * 5)

If lblC1.Caption = 0 Then _ 
lbl1.Caption = "Temporary"

End Sub
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
PaperCut
Registered User
Posts: 10961
Joined: 13 Jan 2006, 02:00
Location: at a place so beautiful, even God has a window...
Contact:

Post by PaperCut »

Hex_Rated wrote:

Code: Select all

Private Sub Command1_Click()
lblC1.Caption = Int(Rnd * 54)
lblC2.Caption = Int(Rnd * 54)
lblC3.Caption = Int(Rnd * 5)

If lblC1.Caption = 0 Then _ 
lbl1.Caption = "Temporary"

End Sub
FAIL!
You need an 'End If' for every 'If'... otherwise...
DJT wrote:I get a compile error. Block if without End if
:wink:
/. Image /. Image /. Image /. Image /.
DJT
I Bribed Ron With Foundry And All I Got Was This Lousy Title
Posts: 9387
Joined: 09 Aug 2002, 02:00
Location: Locked Down
Contact:

Post by DJT »

PaperCut wrote:
Hex_Rated wrote:

Code: Select all

Private Sub Command1_Click()
lblC1.Caption = Int(Rnd * 54)
lblC2.Caption = Int(Rnd * 54)
lblC3.Caption = Int(Rnd * 5)

If lblC1.Caption = 0 Then _ 
lbl1.Caption = "Temporary"

End Sub
FAIL!
You need an 'End If' for every 'If'... otherwise...
DJT wrote:I get a compile error. Block if without End if
:wink:
Lol, thanks for trying tho. I figured it out and all 150 numbers have been programmed in. Now to beautify it, and then if you lucky, I will show you all tomorrow :lol:
Want to support my creative work? Drop me a like and subscribe below. It will be greatly appreciated!
Clarke Media - YouTube Channel
Clarke Media - Facebook
GrimStoner
Registered User
Posts: 716
Joined: 08 Oct 2004, 02:00
Contact:

Post by GrimStoner »

I'm guessing you're not only gonna replace the 0's with "Temporary", but all the numbers with different words. So (if your words aren't coming from a data source), make an array, populate it, and use the random number to select one of the array elements, i.e.

Code: Select all

Private Sub Button1_Click()

        'Declare array
        Dim Words(9) As String

        'TODO: Populate Array here
        Words(0) = "Temporary"
        Words(1) = "Test"
        '...

        'Generate 3 random no's
        Dim RandomInt1, RandomInt2, RandomInt3 As Integer

        RandomInt1 = CInt(Rnd() * 10)
        RandomInt2 = CInt(Rnd() * 10)
        RandomInt3 = CInt(Rnd() * 10)

        'Set the label captions
        lblC1.caption = Words(RandomInt1)
        lblC2.caption = Words(RandomInt1)
        lblC3.caption = Words(RandomInt1)

        'etc.

    End Sub
Seems... mendokse though. Explain better what you wanna do.
GrimStoner
Registered User
Posts: 716
Joined: 08 Oct 2004, 02:00
Contact:

Post by GrimStoner »

PaperCut wrote:
Hex_Rated wrote:

Code: Select all

Private Sub Command1_Click()
lblC1.Caption = Int(Rnd * 54)
lblC2.Caption = Int(Rnd * 54)
lblC3.Caption = Int(Rnd * 5)

If lblC1.Caption = 0 Then _ 
lbl1.Caption = "Temporary"

End Sub
FAIL!
You need an 'End If' for every 'If'... otherwise...
DJT wrote:I get a compile error. Block if without End if
:wink:
Um... the _ at the end of the If line is a line continuation character. Don't need an Endif if it isn't in a block.

So, FAIL.
Hex_Rated
Registered User
Posts: 3679
Joined: 19 Jan 2006, 02:00
Contact:

Post by Hex_Rated »

LOL

Failing at failing.
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Zana
Registered User
Posts: 791
Joined: 25 Dec 2007, 02:00
Location: Neverland
Contact:

Post by Zana »

btw , where did VB script originate from?
p.s just passing through and observing... me not a VB gal...lol though i did do some of it in 2002 but lil rusty...
Image
The elvin world is different from your world like our ears compared with yours.. to see all the elfs
Art Gallery: www.zananeichan.deviantart.com
Post Reply