|
-
Aug 18th, 2005, 10:34 PM
#1
Thread Starter
Lively Member
[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
-
Aug 18th, 2005, 10:36 PM
#2
Fanatic Member
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!
-
Aug 18th, 2005, 10:39 PM
#3
Re: How to use Left(or something like it)
VB Code:
Left(strNewMsg, InStrRev(strNewMsg, "BOX:", -1, 1) + 1, Len(strNewMsg) - Len("BOX:"))
-
Aug 18th, 2005, 10:43 PM
#4
Re: How to use Left(or something like it)
 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.
-
Aug 18th, 2005, 10:45 PM
#5
Thread Starter
Lively Member
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
-
Aug 18th, 2005, 10:46 PM
#6
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
-
Aug 18th, 2005, 10:57 PM
#7
Thread Starter
Lively Member
Re: How to use Left(or something like it)
none of those things are working can you give me some other things?
-
Aug 18th, 2005, 10:59 PM
#8
Fanatic Member
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
Here's to us!
Who's like us?
Darned few, and they're all dead!
-
Aug 18th, 2005, 11:02 PM
#9
Thread Starter
Lively Member
Re: How to use Left(or something like it)
 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
-
Aug 18th, 2005, 11:05 PM
#10
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|