vbr666
asked on
Textbox problem
I'm trying to make an application which communicates with windows command prompt and I have 3 questions:
1) How can I subtract last character from a textbox Text1 and show the rest of chars(except that last one) in txtbox Text2?
For example:If this is written in Text1: "This is test line1" how can I subtract its last character so I get this in Text2: "This is test line" ?
I've tried this:
Dim a
b="1"
a = Len(Text3.Text) - b
Text4.Text = a(the number of chars without that last one is shown in text4.)
2) How can I "find" the group of certain characters(a word for example) among other characters(other words) in textbox and then delete that certain group of chars?
For example:
Text written in textbox Text1 is: "cmd /c cd..&&cd&&dir&&cd ASDF&&cd"
Now, how can I select a word "dir" in that line in Text1 and delete it without changing the rest of that line?
3) how can I achieve that when I type "cd.." the program automatically adds "&&cd" anywhere in that textbox(not only in the beginning of the line)?
1) How can I subtract last character from a textbox Text1 and show the rest of chars(except that last one) in txtbox Text2?
For example:If this is written in Text1: "This is test line1" how can I subtract its last character so I get this in Text2: "This is test line" ?
I've tried this:
Dim a
b="1"
a = Len(Text3.Text) - b
Text4.Text = a(the number of chars without that last one is shown in text4.)
2) How can I "find" the group of certain characters(a word for example) among other characters(other words) in textbox and then delete that certain group of chars?
For example:
Text written in textbox Text1 is: "cmd /c cd..&&cd&&dir&&cd ASDF&&cd"
Now, how can I select a word "dir" in that line in Text1 and delete it without changing the rest of that line?
3) how can I achieve that when I type "cd.." the program automatically adds "&&cd" anywhere in that textbox(not only in the beginning of the line)?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Problem 3 is not important, I solved it.
I've got another problem.
If this:
Private Sub Text1_Change()
Dim cc As String
Text2.Text = Text1.Text
bb = Text2.Text
cc = Replace$(bb, "xx", "yy")
If Right(Text1.Text, 2) = "xx" Then
cc
End If
End Sub
Then I get "Expected Sub, Function or Property" error.
Why? How to solve it?
I've got another problem.
If this:
Private Sub Text1_Change()
Dim cc As String
Text2.Text = Text1.Text
bb = Text2.Text
cc = Replace$(bb, "xx", "yy")
If Right(Text1.Text, 2) = "xx" Then
cc
End If
End Sub
Then I get "Expected Sub, Function or Property" error.
Why? How to solve it?
ASKER
ok no need answering i found the "problem"
ASKER
i'm gonna give you all points but when i finish what im doing now.that will be soon i think
ASKER
Problem #5
When I send command prompts output(I've created a client/server application which communicates with cmd) from client to server after executing "dir" command( and the list of files is long) the first part of the list in textbox is erased and i cant use scrollbar to scroll to the beginning. That happens only when I send the cmd's output from client to server but in client application's textbox I can scroll to the beginning normally. Why is this happening? How to solve this?
Problem #6
When I type a command in a txtbox in which multiline is disabled and press enter to enter the command in command prompt the windows plays annoying "beep" sound trying to tell me there is no another line(multiline=false), but when I type command and press enter in a multiline txtbox the sound isn't played and that's ok but problem is that I'm sending that command from server to client and when I press enter it sends the enterkey sign(two parallel lines, something like "ll") in vb to the client and the command can't be recognized. I tryed to "repair" this by sending text without last character but program works wrong. It sends "ll" but doesn't send the last char from command I really wanted to send.
To make it clearer:
if I write "dir" and press enter it would send "dirll" and command wouldn't be recognized but if I subtract last character it would send "dill"(without r).
How can i get rid of anoying sound and stupid enterkey sign("ll") and send the real command in whole?!?
I'M GIVING THE EXTRA POINTS FOR THIS SO PLEASE HELP!
When I send command prompts output(I've created a client/server application which communicates with cmd) from client to server after executing "dir" command( and the list of files is long) the first part of the list in textbox is erased and i cant use scrollbar to scroll to the beginning. That happens only when I send the cmd's output from client to server but in client application's textbox I can scroll to the beginning normally. Why is this happening? How to solve this?
Problem #6
When I type a command in a txtbox in which multiline is disabled and press enter to enter the command in command prompt the windows plays annoying "beep" sound trying to tell me there is no another line(multiline=false), but when I type command and press enter in a multiline txtbox the sound isn't played and that's ok but problem is that I'm sending that command from server to client and when I press enter it sends the enterkey sign(two parallel lines, something like "ll") in vb to the client and the command can't be recognized. I tryed to "repair" this by sending text without last character but program works wrong. It sends "ll" but doesn't send the last char from command I really wanted to send.
To make it clearer:
if I write "dir" and press enter it would send "dirll" and command wouldn't be recognized but if I subtract last character it would send "dill"(without r).
How can i get rid of anoying sound and stupid enterkey sign("ll") and send the real command in whole?!?
I'M GIVING THE EXTRA POINTS FOR THIS SO PLEASE HELP!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanx for the code above,it solved problem 6,but do you have any ideas about problem 5?
ASKER
Ok I solved problem 5 but I have one more and final question.
Im having trouble sending all of the command prompt's output text and I need to send the last 64K(65536 bytes).
How can I send via winsock or just transfer from one txtbox to another the last 64K of text data or some other amount of data?
Im having trouble sending all of the command prompt's output text and I need to send the last 64K(65536 bytes).
How can I send via winsock or just transfer from one txtbox to another the last 64K of text data or some other amount of data?
ASKER
CAN ANYBODY HELP?!
ASKER
I've learned that txtbox can hold 32Kbytes of text and I think that winsock can send only about 2KB of data in a single send event but I know that sending larger files can be achieved using chunks of data and I've successfully sent a larger file and that's ok but how can I send text in chunks(I want to send a text from one txtbox on a client's form to another on a server's form in a chunks of perharps 2KB)? Can you give me a hint or some link of a possible solution? Please help.
Is this code for reading txt files ok?
Dim filenumber As Integer, length As Long
filenumber = FreeFile
Open "c:\log.txt" For Input As filenumber
length = LOF(filenumber)
If length < 32767 Then
Text1.Text = Input$(length, filenumber)
Else
MsgBox "This file is longer than 32Kb"
End If
Close filenumber
Is this code for reading txt files ok?
Dim filenumber As Integer, length As Long
filenumber = FreeFile
Open "c:\log.txt" For Input As filenumber
length = LOF(filenumber)
If length < 32767 Then
Text1.Text = Input$(length, filenumber)
Else
MsgBox "This file is longer than 32Kb"
End If
Close filenumber
Text4.Text = Mid$(Text3.Text, 1, Len(Text3.Text) - 1)
2-
Text1.Text = Replace(Text1.Text,"dir","
For #3, do you want to add it to a specific position?