|
yeah you are right the textbox is empty but man i want to write "ssss" in the textbox
|
|
|
|
|
You don't need a textwriter for that. What you are attempting to do with your code is write the text "sssss" to a file on your harddrive. The file to be written to would be whatever the path is in the textbox. If you want to set the text of the textbox just use:
lkj.text = "ssss"
|
|
|
|
|
yeah buddy, i know this , i want to do this in another way,
my whole problem is that ,i create an application in which Richtextbox contains about 10 lines of numbers
eg.
10
121
153....
and i want to add the textbox`s number which will be enter by user in every line thats why i was asking for textwriter
|
|
|
|
|
It took you 5 and a half hours to FINALLY describe what your trying to do with this instead of insisting that you need a TextWriter. You don't. If all you want to do is add the Text typed in by the user to the RTB, then all you have to do is:
myRTB.AppendText(myTextBox.Text & Environment.NewLine)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hehe ,nice and thanks i will check it,
|
|
|
|
|
buddy it adding lines at the end of text
it wont add the given number to line
|
|
|
|
|
The code provided will add whatever text is in the textbox to the end of the RTB. If the textbox is empty it will add a blank line. Just enter your number into the textbox and click the button.
|
|
|
|
|
Then you're going to have to re-explain and draw some text pictures of what you want it to do because as of right now, noone understands what you want it to do. And DON'T use what you've already posted.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
ok listen i want to add (eg.10+1=11) number which will in textbox to rtb lines so i coded it like this:
Dim srr As TextReader = New StringReader(rtb.Text)
Dim lineIn As String = ""
While Not (srr.Peek = -1)
lineIn = srr.ReadLine
lineIn = Val(lineIn) + Val(textbox.Text)
End while
its reading the lines but how to put back the value of "lineIn" in the place of same line where it read
now i think you will understand my problem
|
|
|
|
|
OK. You STILL do not need a StreamReader for this. And I STILL don't understand what you're trying to do. But, to get through the lines of an RTB is very easy using it's Lines property:
Dim newText As New StringBuilder()
For x As Integer = 0 To RichTextBox1.Lines.Length - 1
newText.AppendLine("test " & RichTextBox1.Lines(x))
Next
RichTextBox1.Text = newText.ToString()
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thanks for help but buddy why you use "-1" in this
For x As Integer = 0 To RichTextBox1.Lines.Length - 1
and i hope it will help me by the way my problem is:
i have a textbox and rtb ,rtb contains 10 or more numerical lines
and i want when i click on button then the number in textbox shoud be add in all lines of rtb
[eg:10(rtb line number)+1(textbox number)=11(10 change to 11)]
|
|
|
|
|
Richtextbox1.lines is an array. Richtextbox1.lines.length returns the number of lines in the richtextbox. However arrays start at zero. So to access the first element you would use Richtextbox1.lines(0). If there are 10 lines the 10th line would be Richtextbox1.lines(9). So to iterate over all the lines you go from 0 to 9 or 0 to length -1.
The code provided will do just what you want. All you need to do is make a small modification to add the value in the textbox.
Dim newText As New System.Text.StringBuilder
For x As Integer = 0 To RichTextBox1.Lines.Length - 1
Dim val As Integer = Integer.Parse(RichTextBox1.Lines(x)) + Integer.Parse(TextBox1.Text)
newText.AppendLine(val.ToString)
Next
RichTextBox1.Text = newText.ToString.Trim
|
|
|
|
|
thanks buddy i hope it should be work
thanks again for spend your time on it
|
|
|
|
|
Dear friends, i tried to check textbox
if textbox.text is empty i want to show a message like "Please write your name"
but unfortunately i couldn't check textbox.text is empty or not?
Thank you for your helping
Public Sub Kontrol()
If RdbMale.Checked = False And RdbFemale.Checked = False Then
MsgBox("Please choose Gender")
If TxtName.Text="" Then
MessageBox.Show("Please write your name")
If RdbMale.Checked = True Then
MaleFemale = "Male"
If RdbFemale.Checked = True Then
MaleFemale = "Female"
End If
End If
End If
End If
End Sub
MAGICIANMERLIN
|
|
|
|
|
MAGICIANMERLIN wrote: but unfortunately i couldn't check textbox.text is empty or not?
What do you mean ? Did you step through the code to see what was happening ?
Try this
if string.IsNullOrEmpty(TxtName.Text.Trim()) then
end if
This does two things
1 - it checks properly for an empty string
2 - it removes whitespace, so if the box LOOKS empty, it will be. Otherwise, a box with a space in it, is not empty.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you very much
it solved my trouble, thank you Christian
|
|
|
|
|
Glad to help
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am trying to use a BackgroundWorker to list each file that I am scanning, but I'm not sure where to start. The MSDN examples don't help much. How should I use a BackgroundWorker for something like that?
Thanks!
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
What do you want the thread to do ? Read some files ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
No, I am trying to list each file in a directory (a label will display the path/file that is being listed). But I need a background worker so my app won't lock up while searching.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
How long does it take ?
It sounds like a pretty easy task, you create a thread which calls Directory.GetFiles, and stores that value in a member variable, which you read from in the worker completed event.
Which bit is causing you trouble ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: It sounds like a pretty easy task, you create a thread which calls Directory.GetFiles
That's the part I'm not sure about. How do I create a new thread?
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
You create a BackgroundWorker, you set it's DoWork and RunWorkerCompleted events, then you call it's RunWorkerAsync method.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Ok, I've tried messing with it some and it seems pretty easy, but I still can't get it to work.
Here's what I'm doing:
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BackWork.WorkerReportsProgress = True
BackWork.RunWorkerAsync()
End Sub
Private Sub BackWork_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackWork.DoWork
For Each file In My.Computer.FileSystem.GetFiles("C:\", FileIO.SearchOption.SearchAllSubDirectories)
'Status is a Label
Status.Text = file
Next
End Sub
Private Sub BackWork_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackWork.ProgressChanged
Status.Text = file
End Sub
Thanks for the help!
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
grettings gentlemen
i've been only given a WSDL file and i have to use that file in a VB.net win forms aplication to consume the given web service.
i've read much about WSDL, SOAP, UDDI, web services, etc.
everyone points very clear what is what and how its supposed to work.
but none makes clear the "how to introduce the wsdl file into the project"
i just want to know how to use the wsdl file to reach its web methods and how to save the resulting xml from the methods.
my idea is to insert the wsdl into the project. then a button triggers the code to call the webmethod, then the result is saved into a xml, then with a xml data adapter turn this xml into a dataset. then using the dataset fill a datagridview control to show it to the user.
i simply dont know how...
any help would be appreciated, later with this experience i prommise im gonna make an article about this
"WSDL in practice, step by step", trying to be not so specific about the theory but in the practice.
thanks for your time
|
|
|
|