Valhalla Legends Forums Archive | Visual Basic Programming | icon trouble

AuthorMessageTime
QwertyMonster
Hello, some of you may know me, some might not!

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

[code]

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

[/code]

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

I put
[code]
Function Icons(ByVal Product As String)
[/code]

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

[code]
Function Icons (Optional ByVal product as string)
[/code]

and i get no error but no icons either!


If somebody could help me please i would appreciate it !


{{{ == QwertyMonster == }}}
January 29, 2005, 3:47 PM
KkBlazekK
Are your sure the product your getting isn't "RATS" or "PXES"?
January 29, 2005, 3:49 PM
Newby
Try using a switch statement instead of your horrible set of if statements.

Err, select case.
January 29, 2005, 4:14 PM
QwertyMonster
I put

[code]
Msgbox Product
[/code]
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
[code]
Function Icons (Byval product as string)
[/code]
and when i dont have it its ok but doesnt work?
January 29, 2005, 4:29 PM
Newby
Try something like this (psuedo-code)

[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
[/code]
And call it as such:

[code]Call listview.listitems.add(username, , , GetIconCode(Product))[/code]
I haven't touched any Visual Basic for projects of mine in a while. :(
January 29, 2005, 4:32 PM
QwertyMonster
whats the

[code]
UCase(Product)
[/code]

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 :) ]
January 29, 2005, 4:35 PM
QwertyMonster
Umm i have tried it, and it doesnt add icon, :(

Anybody got any ideas?
January 29, 2005, 4:59 PM
Newby
Are you passing in anything when you pass in the product?

UCase(string) makes the string all uppercase.

Example: Hello there! becomes HELLO THERE!
January 29, 2005, 5:27 PM
QwertyMonster
Well what i have is:

[code]

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

[/code]

If i just put

[code]
Icons(Product))
[/code]
i get "Sub or function not defined"

so i put

[code]
Everything.Icons(Product))
[/code] and it worked

im sure im passing through something when i pass in the product ..  :-\ :-\ :-\
January 29, 2005, 5:40 PM
QwertyMonster
oh btw Newby, can you add me on msn so we can talk better? ive just added you now
January 29, 2005, 5:45 PM
QwertyMonster
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.
January 29, 2005, 7:47 PM
QwertyMonster
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

[code]
ListView1.listitems.add, ,frmconfig.username , 1
[/code]

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  :-[ :'(
January 31, 2005, 6:17 PM
Quarantine
Are you initializing the imagelist?



-- Also how can you have made a Bot and not know what UCase does?
February 4, 2005, 1:05 AM
QwertyMonster
Cos i dont use UCase Much o_O
February 4, 2005, 12:16 PM
Quarantine
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?
February 4, 2005, 2:00 PM
QwertyMonster
[quote author=Warrior link=topic=10353.msg98191#msg98191 date=1107525647]

Was that so hard?
[/quote]

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

Back on track, any ideas..
February 4, 2005, 2:21 PM
Quarantine
but my other post did, try rereading my posts.
February 4, 2005, 4:38 PM
QwertyMonster
[quote author=Warrior link=topic=10353.msg98136#msg98136 date=1107479131]
Are you initializing the imagelist?
[/quote]

Yes.

Ok my bot adds icons when i tell it to, but it doesnt add the proper product icons, ideas?
February 5, 2005, 11:52 AM
UnLeaDeD
Icons.bni is nice because everytime bnet comes out with a new icon its automatically read. Just a thought.
February 6, 2005, 4:43 AM
Quarantine
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?
February 6, 2005, 4:56 AM
UnLeaDeD
: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
February 6, 2005, 5:21 AM
QwertyMonster
Uh ok, i was trying and i have this:

[code]
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
[/code]

Just to test out starcraft and broodwar.

[code]
icon = Events.geticon


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

[/code]

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?
February 6, 2005, 9:23 AM
JoeTheOdd
Declare your icon integers, such as..
[code]Public Const iSTAR as Integer = 1[/code]

[code]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[/code]
February 8, 2005, 4:27 AM

Search