Results 1 to 10 of 10

Thread: [RESOLVED] How to use Left(or something like it)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Resolved [RESOLVED] How to use Left(or something like it)

    ok my problem is i have a program that uses winsock to send a message called
    "BOX:" and then the message an when the client gets the message i want it to be displayed in a message box

    Example
    Server->sends "BOX:" & "TESt"

    the client would get "BOX:TEST" how can i make it so the BOX: doest appear in the message box

    (sorry if this is confusing)

    -BladeZ

  2. #2
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627

    Re: How to use Left(or something like it)

    You can use the replace function to get rid of it.

    strMessage = replace(strMessage, "BOX:", "")
    Here's to us!
    Who's like us?
    Darned few, and they're all dead!

  3. #3
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: How to use Left(or something like it)

    VB Code:
    1. Left(strNewMsg, InStrRev(strNewMsg, "BOX:", -1, 1) + 1, Len(strNewMsg) - Len("BOX:"))

  4. #4
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: How to use Left(or something like it)

    Quote Originally Posted by demotivater
    You can use the replace function to get rid of it.

    strMessage = replace(strMessage, "BOX:", "")
    good one sorry did not see that.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Re: How to use Left(or something like it)

    this is what im trying to do

    SERVER
    VB Code:
    1. Form1.winsock.SendData "BOX:" & txtmsg.Text

    Client
    VB Code:
    1. If strinput = "BOX:" Then
    2. stroutput = Replace(incommingData, "BOX:", "")
    3. msgbox stroutput, vbCritical, "Admin Message"
    4. End If

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How to use Left(or something like it)

    Or this:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   Dim t$
    5.   t = "Box: test"
    6.   MsgBox Trim(Right$(t, InStr(t, ":")))
    7. End Sub

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Re: How to use Left(or something like it)

    none of those things are working can you give me some other things?

  8. #8
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627

    Re: How to use Left(or something like it)

    How is the variable "incomingdata" being filled?

    Try something like this (assumes strinput is from winsock send data)

    VB Code:
    1. If InStr(strinput, "BOX:") > 0 Then
    2.     stroutput = Replace(strinput, "BOX:", "")
    3.     MsgBox stroutput, vbCritical, "Admin Message"
    4. End If
    Here's to us!
    Who's like us?
    Darned few, and they're all dead!

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    73

    Re: How to use Left(or something like it)

    Quote Originally Posted by demotivater
    How is the variable "incomingdata" being filled?

    Try something like this (assumes strinput is from winsock send data)

    VB Code:
    1. If InStr(strinput, "BOX:") > 0 Then
    2.     stroutput = Replace(strinput, "BOX:", "")
    3.     MsgBox stroutput, vbCritical, "Admin Message"
    4. End If

    thanks man that works perfect

  10. #10
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    Re: [RESOLVED] How to use Left(or something like it)

    Hi did something like this before for a Chat Room app. I used something like this.

    Function Token(lpStr As String) As String
    Dim x As Integer
    Dim mByte() As Byte, i_pos As Integer

    Token = vbNullString
    mByte = StrConv(lpStr, vbFromUnicode)
    For x = 0 To UBound(mByte)
    If mByte(x) = 58 Then 'check for :
    i_pos = x
    Exit For
    End If
    Next

    Erase mByte

    If i_pos <> 0 Then
    Token = Trim$(Mid(lpStr, i_pos + 2, Len(lpStr)))
    End If

    End Function

    Private Sub Command1_Click()
    MsgBox Token("Client: Login[usr:pass]") 'Returns Login[usr:pass]
    End Sub

    Hope it may also help.
    When your dreams come true.
    On error resume pulling hair out.

Posting Permissions

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



Click Here to Expand Forum to Full Width