[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
Re: How to use Left(or something like it)
You can use the replace function to get rid of it.
strMessage = replace(strMessage, "BOX:", "")
Re: How to use Left(or something like it)
VB Code:
Left(strNewMsg, InStrRev(strNewMsg, "BOX:", -1, 1) + 1, Len(strNewMsg) - Len("BOX:"))
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 :D sorry did not see that. ;)
Re: How to use Left(or something like it)
this is what im trying to do
SERVER
VB Code:
Form1.winsock.SendData "BOX:" & txtmsg.Text
Client
VB Code:
If strinput = "BOX:" Then
stroutput = Replace(incommingData, "BOX:", "")
msgbox stroutput, vbCritical, "Admin Message"
End If
Re: How to use Left(or something like it)
Or this:
VB Code:
Option Explicit
Private Sub Form_Load()
Dim t$
t = "Box: test"
MsgBox Trim(Right$(t, InStr(t, ":")))
End Sub
Re: How to use Left(or something like it)
none of those things are working can you give me some other things?
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:
If InStr(strinput, "BOX:") > 0 Then
stroutput = Replace(strinput, "BOX:", "")
MsgBox stroutput, vbCritical, "Admin Message"
End If
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:
If InStr(strinput, "BOX:") > 0 Then
stroutput = Replace(strinput, "BOX:", "")
MsgBox stroutput, vbCritical, "Admin Message"
End If
thanks man that works perfect
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.