Thread

VB Removing a List Item by String (Sdk)

VB Removing a List Item by String // Sdk

1  |  

gamer

May 6, 2001, 10:00am
This is a multi-part message in MIME format.

------=_NextPart_000_0048_01C0D62C.E1D658C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, sorry to make yet another request, but I'm trying to create a list =
of people within the radius of the bot. Like the Xelagot does but just a =
simple list version.

How can I make VB remove a list item by its string and not its heirachy =
number in the list...

So basically:

Private Sub sdk_EventAvatarDelete()
printf sdk.AwAvatarName & " has left"
List2.RemoveItem (what do I put here?)
End Sub

Sorry about HTML posting too..needed to use color for code...

Thanx in advance..

-Gamer

------=_NextPart_000_0048_01C0D62C.E1D658C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi, sorry to make yet another request, =
but I'm=20
trying to create a list of people within the radius of the bot. Like the =
Xelagot=20
does but just a simple list version.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>How can I make VB remove a list item by =
its string=20
and not its heirachy number in the list...</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So basically:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Private Sub =
sdk_EventAvatarDelete()<BR>&nbsp;&nbsp;=20
printf sdk.AwAvatarName &amp; " has left"<BR>&nbsp;&nbsp; =
List2.RemoveItem <FONT=20
color=3D#ff0000>(what do I put here?)</FONT><BR>End Sub</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sorry about HTML posting too..needed to =
use color=20
for code...</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanx in advance..</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-Gamer</FONT></DIV></BODY></HTML>

------=_NextPart_000_0048_01C0D62C.E1D658C0--

kah

May 6, 2001, 10:59am
a complicated option would be to register a custom type, that stores info
about everybody that enters the hearing-range, so that the bot can use the
ListIndex... and you don't need to use HTML to do it, I guess that you
copyed it from VB and that the message formatted itself, but there's a
solution to make it plain text: use the Format > Plain Text menu :-))
remember, if everybody posted in HTML, it would increase the article
database's size by 300 %

KAH
[View Quote] How can I make VB remove a list item by its string and not its heirachy
number in the list...

So basically:

Private Sub sdk_EventAvatarDelete()
printf sdk.AwAvatarName & " has left"
List2.RemoveItem (what do I put here?)
End Sub

Sorry about HTML posting too..needed to use color for code...

Thanx in advance..

-Gamer

baron

May 6, 2001, 11:03am
Well everyone does it his own way, there are many ways to do it. In cases like this I preffer to use the ItemData property. On Avatar_Add set: list2.ItemData(list2.NewIndex) = sdk.AwAvatarSession. On Avatar_Delete search the Itemdata array for the session# and remove the item

Dim i as integer
For i=0 to list2.ListCount
If list2.ItemData(i)=sdk.AwAvatarSession. Then
list2.RemoveItem (i)
Exit For
End If
Next i

HTH
Baron




[View Quote] How can I make VB remove a list item by its string and not its heirachy number in the list...

So basically:

Private Sub sdk_EventAvatarDelete()
printf sdk.AwAvatarName & " has left"
List2.RemoveItem (what do I put here?)
End Sub

Sorry about HTML posting too..needed to use color for code...

Thanx in advance..

-Gamer

baron

May 6, 2001, 1:06pm
Actually that should read For i=0 to list2.ListCount - 1. Exit For prevents the error since it exits the loop before the loop checks for the value of an array element that doesn't exist (list2.itemdata(listcount)) , but the syntax was not correct, sorry about that.

Baron



[View Quote]

m a k a v e l i

May 6, 2001, 2:15pm
Why do you make it harder than it is?

Private Sub sdk_EventAvatarDelete()
List2.Text = sdk.AwAvatarName
If List2.ListIndex = -1 Then Exit Sub
List2.RemoveItem List2.ListIndex
End Sub

To break it down so you understand the simplicity:

All lists have a [Text] field that can be used to view the selected item's
value; so if you add the avatar's name to the list's text field it will
select the name (if in the list) and have the .ListIndex value as the number
of the item.

If the name isn't in the list, it responds -1 so if you don't exit sub if it
responds -1, it will error "Type mismatch".

If it doesn't exit sub, it will continue to the next part, it will remove
the selected item, which is the avatar's name.

Have fun!

trekkerx

May 6, 2001, 4:09pm
If you want to do it you have to do it like this...

Private Sub sdk_EventAvatarDelete()
Dim word as string

For word = 1 to List2.ListCount - 1
If List1.list(word) = Sdk.AwAvatarName Then
List2.RemoveItem word
End If
Next Word


It should then remove the name of the person from the list box.
[View Quote] > Why do you make it harder than it is?
>
> Private Sub sdk_EventAvatarDelete()
> List2.Text = sdk.AwAvatarName
> If List2.ListIndex = -1 Then Exit Sub
> List2.RemoveItem List2.ListIndex
> End Sub
>
> To break it down so you understand the simplicity:
>
> All lists have a [Text] field that can be used to view the selected item's
> value; so if you add the avatar's name to the list's text field it will
> select the name (if in the list) and have the .ListIndex value as the number
> of the item.
>
> If the name isn't in the list, it responds -1 so if you don't exit sub if it
> responds -1, it will error "Type mismatch".
>
> If it doesn't exit sub, it will continue to the next part, it will remove
> the selected item, which is the avatar's name.
>
> Have fun!

m a k a v e l i

May 6, 2001, 5:59pm
TrekkerX, have you gone mad?
The simple way to do it is the best, why do such hard things, when it can be
done simple?

| Private Sub sdk_EventAvatarDelete()
| Dim word as string
|
| For word = 1 to List2.ListCount - 1
| If List1.list(word) = Sdk.AwAvatarName Then
| List2.RemoveItem word
| End If
| Next Word
|
|
| It should then remove the name of the person from the list box.

kah

May 6, 2001, 6:02pm
lol, both of you do it the hard way! using ElseIf or Case is easyest!

KAH

[View Quote]

m a k a v e l i

May 6, 2001, 6:08pm
No Case is about the dumbest way of doing this type of thing. Why would you
use a Case statement in this anyway? I am not even sure if you can do it
case and you other post:

<snip>
If sdk.AwChatMessage = "you are a donkey" Then
sdk.AwSay "I am not!"
ElseIf sdk.AwChatMessage = "you are a Xelagot" Then
<end snip>

That is about a dumb thing to do, why use ElseIf if you would use End If,
and start a new If? I don't understand why you try to make it so hard?

azazael

May 6, 2001, 6:24pm
Do you actually know what a Case statement does Makaveli? I wonder...

Regards
Az

[View Quote]

m a k a v e l i

May 6, 2001, 6:32pm
*sigh* You show me how your going to take a name out of a list just using a
Case statement and I will shut up, otherwise don't try to prove me wrong.

kah

May 6, 2001, 6:58pm
why use ElseIf: it's correct programming syntax! Even if you CAN just use
If, EndIf, If, EndIf, that isn't the CORRECT way to do it...

KAH

[View Quote]

m a k a v e l i

May 6, 2001, 8:12pm
Yes, that is the correct way to do it, like my teachers say "The can be more
than ONE way of doing something."

trekkerx

May 6, 2001, 10:33pm
Then your teachers are stupid, did they ever learn the correct way to speak
english?
ether you ment "There" or your teachers are idiots

[View Quote] > Yes, that is the correct way to do it, like my teachers say "The can be more
> than ONE way of doing something."

m a k a v e l i

May 6, 2001, 11:05pm
I meant There, you really need to not talk that way about people until you
look in the mirror, you repeated 2 things I posted in the subject of Gamer's
new bot release. So who is the idiot now?

| Then your teachers are stupid, did they ever learn the correct way to
speak
| english?
| ether you ment "There" or your teachers are idiots

tony m

May 7, 2001, 1:04am
Hrm, this is an interesting slap fight.

Both the "Case" and "ElseIf" statements are correct forms of
programming. It's just that some programmers find a "Case" statement
more efficient than a cluster of "ElseIfs". Azazael is right when he
says it makes code more efficient to read. Nobody is wrong here;
everybody is actually right. There are different ways to do different
things, just like there are different languages to make different
programs :o)

grimble

May 7, 2001, 2:19am
Generally speaking, Select statements ("Case"s) build jump tables which are
faster than a sequential list if If/ElseIf/ElseIf/EndIfs but at the end of
the day, when you're writing an application in VB, the speed of an
infrequent check like in an aw_event_avatar_add message isn't really going
to make too much difference is it! . In makaveli's example, there's no gain
in ElseIfs because the conditions were all on the same variable. Its going
to have to check it every time anyway. ElseIfs are only "better" when one or
more conditions span the If statements to avoid duplicate checking.

If ((a = 1) And (b = 1)) Then
DoStuff_1()
EndIf

If ((a = 1) And (b = 2)) Then
DoStuff_2()
EndIf

If (a <> 1) Then
DoStuff_3()
EndIf

.... Now THAT would be daft!

A lot of the code that gets posted on here is shot to bits anyway, so why
have a "handbags at 3 paces" episode over progamming preferences?

Gamer's not stupid ... he's not looking for the exact code ... just a
pointer to the correct solution (or even just A solution). Surprise,
surprise, m a k a v e l i (GRRR to spaces in names) is at the centre of
another non-sensical argument.

Grims

[View Quote]

grimble

May 7, 2001, 3:46pm
Geesh .. I was asleep yesterday ...

Ignore what I said about "ElseIfs are only better when ..." - I must have
had my eyes shut and my brain turned off.

Grims

[View Quote]

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2021. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn