Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: QwertyMonster on January 29, 2005, 09:47 AM

Title: icon trouble
Post by: QwertyMonster on January 29, 2005, 09:47 AM
Hello, some of you may know me, some might not!

i am trying to program icons into my bot. So far i have this



Function Icons()

             If product = "STAR" Then
                frmMain.ListView1.ListItems.Add , , Username, 1
            Else
             If product = "SEXP" Then
                frmMain.ListView1.ListItems.Add , , Username, 2
            End If
               End If

End Function



I have the Starcraft and Starcraft: Broodwar images in my "ImageList1", as 1 & 2.

I put

Function Icons(ByVal Product As String)


and i get "Arguement not optional". So i put


Function Icons (Optional ByVal product as string)


and i get no error but no icons either!


If somebody could help me please i would appreciate it !


{{{ == QwertyMonster == }}}
Title: Re: icon trouble
Post by: Blaze on January 29, 2005, 09:49 AM
Are your sure the product your getting isn't "RATS" or "PXES"?
Title: Re: icon trouble
Post by: Newby on January 29, 2005, 10:14 AM
Try using a switch statement instead of your horrible set of if statements.

Err, select case.
Title: Re: icon trouble
Post by: QwertyMonster on January 29, 2005, 10:29 AM
I put


Msgbox Product

to see what the product actually is, and i got nothing ;(

i will now try your idea newby

thanks
btw did i post this in the wrong forum? should i post it "Bot devolpment" forum, or is it ok here?
{{{ == QwertyMonster == }}}


[EDIT]

Has anybody any ideas why i get
"Arguement Not Optional"
when i have

Function Icons (Byval product as string)

and when i dont have it its ok but doesnt work?
Title: Re: icon trouble
Post by: Newby on January 29, 2005, 10:32 AM
Try something like this (psuedo-code)


Public Function GetIconCode(ByVal Product As String) As Integer
    Select Case UCase(Product)
        Case "RATS" ' Starcraft
            GetIconCode = 1
        ' Put cases for all the rest of the products
    End Select
End Function

And call it as such:

Call listview.listitems.add(username, , , GetIconCode(Product))
I haven't touched any Visual Basic for projects of mine in a while. :(
Title: Re: icon trouble
Post by: QwertyMonster on January 29, 2005, 10:35 AM
whats the


UCase(Product)


mean? explain what that bit is doing please



ooooooh i see it! thanks for this help newby!

[ still explain what the UCase(Product) bit does though :) ]
Title: Re: icon trouble
Post by: QwertyMonster on January 29, 2005, 10:59 AM
Umm i have tried it, and it doesnt add icon, :(

Anybody got any ideas?
Title: Re: icon trouble
Post by: Newby on January 29, 2005, 11:27 AM
Are you passing in anything when you pass in the product?

UCase(string) makes the string all uppercase.

Example: Hello there! becomes HELLO THERE!
Title: Re: icon trouble
Post by: QwertyMonster on January 29, 2005, 11:40 AM
Well what i have is:



If Mid(data,5,1) = chr(1) then
        If Mid(Data, 5, 1) = Chr(1) Then

        Call ListView1.ListItems.Add(, , Username, everything.Icons(product))

End if



If i just put


Icons(Product))

i get "Sub or function not defined"

so i put


Everything.Icons(Product))
and it worked

im sure im passing through something when i pass in the product ..  :-\ :-\ :-\
Title: Re: icon trouble
Post by: QwertyMonster on January 29, 2005, 11:45 AM
oh btw Newby, can you add me on msn so we can talk better? ive just added you now
Title: Re: icon trouble
Post by: QwertyMonster on January 29, 2005, 01:47 PM
Ok, after help from Newby i finally am getting somewhere :)

By using F9 and F5 I saw that my bot was seeing the icons should be starcraft. But my bot doesnt add them as starcraft and just misses it all out!

Newby was thinking the product wasnt being passed in and wasnt correct for the icons to show. I do too think that is right.

But my question is, how do i "send the right pass product in".

Thanks all.
Title: Re: icon trouble
Post by: QwertyMonster on January 31, 2005, 12:17 PM
Ok. After spending time and looking at my code i relised something was odd.

For just a test i just put the normal code to add a icon, to find that it doesnt add it!

Im thinking maybe the icons are transparent, or maybe its me just coding it wrong?

I have in my ImageList
1- Starcraft icon
2 - Broodwar icon

at the moment


ListView1.listitems.add, ,frmconfig.username , 1


I have that in form_load just for a test and it shows only the username but with a blank square infront. i had it working once, but now it seems dodgey

Maybe they are transparent or something? Because it happens when i add the correct product for other users as well.

Please help  :-[ :'(
Title: Re: icon trouble
Post by: Warrior on February 03, 2005, 07:05 PM
Are you initializing the imagelist?



-- Also how can you have made a Bot and not know what UCase does?
Title: Re: icon trouble
Post by: QwertyMonster on February 04, 2005, 06:16 AM
Cos i dont use UCase Much o_O
Title: Re: icon trouble
Post by: Warrior on February 04, 2005, 08:00 AM
You still should know what it does. I mean it is self explanitory

LCase() uses the lowercase form of a string
UCase() uses the uppercase form of a string

Was that so hard?
Title: Re: icon trouble
Post by: QwertyMonster on February 04, 2005, 08:21 AM
Quote from: Warrior on February 04, 2005, 08:00 AM

Was that so hard?

No, but it still doesnt help me with icons either.

Back on track, any ideas..
Title: Re: icon trouble
Post by: Warrior on February 04, 2005, 10:38 AM
but my other post did, try rereading my posts.
Title: Re: icon trouble
Post by: QwertyMonster on February 05, 2005, 05:52 AM
Quote from: Warrior on February 03, 2005, 07:05 PM
Are you initializing the imagelist?

Yes.

Ok my bot adds icons when i tell it to, but it doesnt add the proper product icons, ideas?
Title: Re: icon trouble
Post by: UnLeaDeD on February 05, 2005, 10:43 PM
Icons.bni is nice because everytime bnet comes out with a new icon its automatically read. Just a thought.
Title: Re: icon trouble
Post by: Warrior on February 05, 2005, 10:56 PM
If he cant get icons from an imagelist to work how in the hell do you expect him to view them directly from the .bni file?
Title: Re: icon trouble
Post by: UnLeaDeD on February 05, 2005, 11:21 PM
:P
Icon = GetIconCode(Message, Flags)
If Icon = ICON_GAVEL Then
    Form1.Roomlist.ListItems.Add 1, , Username, , Icon
        Form1.Roomlist.ListItems(1).ListSubItems.Add , , , Ping
        Form1.Roomlist.ListItems(1).ListSubItems.Add , , Ping
Else
    Form1.Roomlist.ListItems.Add , , Username, , Icon
        Form1.Roomlist.ListItems(Form1.Roomlist.ListItems.Count).ListSubItems.Add , , , Ping
        Form1.Roomlist.ListItems(Form1.Roomlist.ListItems.Count).ListSubItems.Add , , Ping
End If
Title: Re: icon trouble
Post by: QwertyMonster on February 06, 2005, 03:23 AM
Uh ok, i was trying and i have this:


Public Function geticon(Optional ByVal Username As String, Optional ByVal Product As String)

Select Case Mid(Client, 1, 4)
  Case "RATS"
   geticon = 6
  Case "PXES"
   geticon = 9
  Case "STAR"
   geticon = 6
   Case "SEXP"
   geticon = 9
    End Select
    End Function


Just to test out starcraft and broodwar.


icon = Events.geticon


    If Mid(Data, 5, 1) = Chr(1) Then
           
           MsgBox icon
           ListView1.ListItems.Add , , Username, , icon
       End If



Icon comes up as: 99222161

Any ideas people? I will keep trying :(


Edit: I keep getting different numbers, why?!

Edit2: After mcuking around for a while, i finally see that the "Product" is being sent back as "0". And 0 is nothing in my bot so it wont show anything. Any Ideas on how i can get sent the proper product? Maybe i am sending something off wrong? Hmm, ideas please?
Title: Re: icon trouble
Post by: Joe[x86] on February 07, 2005, 10:27 PM
Declare your icon integers, such as..
Public Const iSTAR as Integer = 1

Public Function GetIconCode(Product as String) as Integer
    Select Case UCase(Product)
        Case "RATS", "STAR"
            GetIconCode = iSTAR
            Exit Sub
        Case '// Some other product code..
            GetIconCode = '// The coresponding integer constant
            Exit Sub
        Case Else
            GetIconCode = iSQUELCH '// I guess people make a habbit of making people with unknown icon codes squelched. Hmpg.
            Exit Sub
    End Select
End Function