|
'Array' is a global method in VB6 which takes a parameter array and returns an array of 'Variant'.
You can replace it by:
New Object() {"hello"}
or even better:
New String() {"hello"}
David Anton
Convert between VB, C#, C++, & Java
http://www.tangiblesoftwaresolutions.com
|
|
|
|
|
Hello everyone i am currently trying to figure out to highlight text in a textbox when the user tabs over from textbox to textbox? For example lets say there are 4 TEXTBOXs and the first one displays teh name, 2nd = last name, 3rd= telephone, 4th= GPA, so when the user wants to add another record to the database and after entering in a NEW FIRST NAME, he/she tabs to the lastname text box and IT WOULD HIGHLIGHT THE TEXT and then he could just start entering in new text without having to erase(BACK SPACE what is der)
here is my code of what i got so far. Right now after saving using a button and he tabs it goes and hightlights the text of the FIRSTNAME TEXT BOX
private sub btnSave_Click(blah blah blah)
txtFirst.Focus()
txtFirst.SelectAll() 'selects text in firstname text box after hitting the SAVE BUTTON'
End Sub
I dunno if i would have to use something like TabIndexChanged and tell it to highlight the text?? or what? THANKS
|
|
|
|
|
Hi,
The TabIndex determines the order in which controls get focus when the tab key is hit; as long as you don't change the TabIndex, TabIndexChanged won't fire.
I would go for the Enter and Leave events.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
thanks i GOT IT!!! I used the txt leave event like u said
one little problem when I am working with a masked box, i tried to select all the string in it but it wont, im guessing
since it is a masked box?
I did mskTele.SelectAll()
but it just sets the cursor at the end of the data
|
|
|
|
|
PAguilar09 wrote: im guessing
since it is a masked box?
Guessing isn't very professional. How about studying, researching and trying?
Maybe like so[^].
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
I am working with a textfile; the content of which I have read into a multiline textbox. The number of lines in my textfile will vary from time to time, but I know that the line that I want to modify is always 3rd from the bottom.
for eg.
SM*82*000102339~
my intent is to read the file and modify the 82 to a variable nuCount.
My first thought is to write to an Array and do something. I am stuck. can anyone help me out and put me back on the right track? Thanks
|
|
|
|
|
So, you read the entire contents into an array of Strings, then find the line you want and do some very simple string manipulation. What's the problem? You're stuck on what part of this??
|
|
|
|
|
I'd think he's stuck on the string manipulation bit..
|
|
|
|
|
Nothing a little RegEx couldn't easily handle...
If that's his problem. I wasn't too sure after reading his post a few times.
|
|
|
|
|
How about this:
- forget the multiline TextBox, use a single-line TextBox instead;
- use File.ReadAllLines to get a string array;
- set an integer variable "index" equal to the array length minus 3;
- show the relevant line in the TextBox by setting its Text property;
- have the user edit it and indicate he is done somehow (a "Save" Button would be fine)
- store the TextBox.Text into the same array position you used before;
- and now call the right File method.
Of course if you know exactly what modification has to be applied, you don't need the TextBox at all and you can have your code do it for you.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Luc, thank you for your suggestion. I think I am going to run with it and then repost the solution here. Gracias.
modified on Wednesday, November 25, 2009 12:24 PM
|
|
|
|
|
Still need some help here ..
As Luc suggested, I am using the code below to read a single line to my Textbox. That is working fine. My issue is that I get the last line in the textfile; my solution is to get the 3rd line from the bottom. How do I modify my code to achieve that? Thanks
Dim myFile As New System.IO.StreamReader(frmMain.lblClaimsFile.Text)<br />
Dim strTextArray() As String = {}<br />
Dim intIndex As Integer = 0<br />
<br />
Do Until myFile.EndOfStream = True<br />
ReDim Preserve strTextArray(intIndex)<br />
strTextArray(intIndex) = myFile.ReadLine()<br />
intIndex += 1<br />
Loop<br />
<br />
For i As Integer = 0 To UBound(strTextArray)<br />
txtSEloop.Text = strTextArray(i)<br />
'how do i read the 3rd line from bottom of file?<br />
Next
|
|
|
|
|
Then I suggest you read my earlier message again, up to and including my sig.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Luc, I am a little slow, but I am getting there! lol! the code below gives desired result.
lblNumTrans.Text = frmMain.transLoop<br />
<br />
Dim myFile As New System.IO.StreamReader(frmMain.lblClaimsFile.Text)<br />
Dim strTextArray() As String = {}<br />
Dim intIndex As Integer = 0<br />
<br />
Do Until myFile.EndOfStream = True<br />
ReDim Preserve strTextArray(intIndex)<br />
strTextArray(intIndex) = myFile.ReadLine()<br />
intIndex += 1<br />
Loop<br />
<br />
'read the 3rd line from bottom of file?<br />
For i As Integer = 0 To strTextArray.Length - 3<br />
<br />
txtSEloop.Text = strTextArray(i)<br />
<br />
Next
The last piece I have not yet figured out is how to save what is displayed in my textbox back to the original text file. My issue is that I have the file open for reading. Any help? thanks
|
|
|
|
|
If you were to take my initial advice a quarter of the amount of code shown would have solved it all.
The code you currently have is lacking error handling, it doesn't close files and streams, has two loops it doesn't need, and is not complete. I would waste it.
|
|
|
|
|
Hi everybody
I'm currently developing a 2D RPG game like diablo 2. And this year I finally finished the physics engine .
For drawing the objects I use GDI+. Now I'm working on the level editor and I want to give more freedom for the level designers like giving them the option to decide by their own which regions of the map shall be impassable. The point is to give them a pen tool which they can use to freehand draw the impassable regions - something like Microsoft inkball game(http://www.windowsvistauserguide.com/vista2/games/inkball3.JPG) where you draw a line and when the ball touches the line it bouns from it. For that pen tool I use System.Drawing.Drawing2D.GraphicsPath function - the problem I have is that I don't know how to provide to the level designer a tool for erasing the created impassable regions - do you know a way to erase part of graphic created with System.Drawing.Drawing2D.GraphicsPath function? I've read an article where you can "erase" the created line by drawing another one with the same background color as the containing control but it just didn't work in my case because for background I don't have a solid color but a complex bitmap texture and objects like units and buildings.
Please help, thank you in advance and sorry for my bad english.
|
|
|
|
|
It doesn't sound like you have much of a choice but to repaint everything except the portions you're removing.
|
|
|
|
|
I have a block of code like so; I use to get the number of lines in a text file once I load it in a multiline textbox on my Form1.
Private Sub countLinesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles countLinesToolStripMenuItem.Click<br />
''count claims between ST & SE segments<br />
Dim totLines As String() = IO.File.ReadAllLines(Me.lblClaimsFile.Text)<br />
<br />
MessageBox.Show("The file had " & totLines.Length & " lines before processing.")<br />
End Sub
Once this file is loaded, I do some manipulations, including inserting additional lines. I would like some codes to determine the total number of lines in the textfile after the manipulation.
I am using stringbuilder to load file contents.
Dim newString As New StringBuilder<br />
newString.Append(My.Computer.FileSystem.ReadAllText(FileName))
TIA.
|
|
|
|
|
As you said, you have a multiline text box to load the file. I assume you are editing the file text there itself. Hene if you get the lines count in the multiline text box, I suppose it will be same as that in the file.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
The line count I get on load is static. After inserting additional lines in the file, I need a way to get a dynamic update of the number of lines in the "modified" file. Sorry if this was not clear. thanks
|
|
|
|
|
Have you looked at the Lines property of the TextBox control?
|
|
|
|
|
Thanks Dave. I will give it a whirl.
|
|
|
|
|
If you want to find out the number of lines in the textbox, use:
int lineCount = textBox1.Lines.Count;
|
|
|
|
|
Thanks Shameel .. it worked great; I just had to use Length instead of Count (since I got a message that count was not in the array).
Dim lineCount As String<br />
lineCount = txtClaimsDetail.Lines.Length<br />
MessageBox.Show("You have " & lineCount & " in your batch")
|
|
|
|
|
yep, I forgot. Arrays have a Length property and Collections have a Count property.
|
|
|
|