PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Object Required-VBForums
Results 1 to 14 of 14

Thread: Object Required

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    84

    Object Required

    Alright I'm getting this stupid error for some reason. I don't think I did anything wrong with my code.
    vb Code:
    1. Name = Split(Data, "name")
    2. pInfo.Player(Index).Nick = Name(1)
    Data is "nameHell", Here is source for Player() and pInfo.
    vb Code:
    1. Private Type PlayerData
    2.     Nick As String
    3.     Cash As Long
    4.     XYZ As Variant
    5.     Health As Single
    6.     IP As Variant
    7. End Type
    8.  
    9. Private Type pInfo
    10.     Players(1 To 20) As PlayerData
    11. End Type
    Last edited by Hellomy; Oct 27th, 2007 at 01:49 PM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    84

    Re: Object Required

    I see. Thanks.

  3. #3

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    84

    Re: [Solved] Object Required

    I don't get it. Mind showing me?

  5. #5
    Member
    Join Date
    May 2006
    Posts
    32

    Re: [Solved] Object Required

    Quote Originally Posted by Hellomy
    I don't get it. Mind showing me?
    vb Code:
    1. Dim pI As pInfo
    2. Name = Split(Data, "name")
    3. pI.Player(Index).Nick = Name(1)

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    84

    Re: Object Required

    It's giving me subscript out of range error now for pI.Player(Index).Nick = Name(1) .

  7. #7
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Object Required

    What is your Index Value? and we have no idea of what your data looks like...

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    84

    Re: Object Required

    Index value comes from Winsock(Data Arrival). Data = nameHello

  9. #9
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Object Required

    That still doesn't help. Where it comes from is irrelevant. What it's value is, is relevant.

    BTW with data like nameHello when you split it you will only have one index and it will be 0. Try going thru the debugger.

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: Object Required

    If you split "nameHello" by "name", you get 1 element in Name, Name(0). There's no Name(1).
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  11. #11

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    84

    Re: Object Required

    So Name(0) = Hello or no

  12. #12
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Object Required

    No. Name(0) would equal nameHello - as Al42 says, there is no Name(1) and that is your subscript that is out of range.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  13. #13
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Object Required

    Hmmm, isn't that just what I stated????

  14. #14
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: Object Required

    Hellomy, if you want Name(0) = "name" and Name(1) = "Hello", you're going to have to hard code it. Split only works if there's a common string in each element - like

    str = "My Name Is Hellomy"
    Name = Split(str, " ")

    Now Name(0) = "My", Name(1) = "Name", Name(2) = "Is" and Name(3) = "Hellomy". The space (" ") is the common character on which the string gets split.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width