
gkiril
Members-
Posts
21 -
Joined
-
Last visited
gkiril's Achievements
Newbie (1/14)
0
Reputation
-
Okay, in the short time since my last post, I have been playing with my code. I implemented txtrange.text.trim and that seems to have cleared up the problems with searching and finding the string in my text file. I would prefer to use txtrange.htmltext, but I know no way of preventing that closing tag from being appended to the selection. Damn it!!! Anyway, the ONLY problem with txtrange.text is that if your selection breaks an element, for instance spanning "the quick <i>brown", it will not be recognized because, after all, it is only reading the text and not the underlying html. Consequently, I am now turning my attention to the code above to see about truncating the text to the first element encounted. As always, any words of advice are appreciated. -gk
-
Hello all, sorry for not responding... I've been away and another bit of my code had my attention. The txtrange object is not the name of a text area or box, it is an Ihtmltxtrange object. I have the truncation problem solved, using .movetoend and doing some basic algebra to calculate x and y type values. This works pretty well. I need to figure out a way to capture the first and last words of the selection, so I will be trying the solution given above in a day or two, but before that, I have discovered an interesting problem. If I set a txtrange and retrieve the .htmltext, the retrieval process automatically appends the relevant closing tag, even if your selection did not include the closing tag to begin with. Very frustrating given that I would like to replace only the .htmltext selected. See, you cannot use a find and replace function like with the "Scripting.FileSystemObject" because the source string NEVER matches the text for which you are searching. Example... say you select the text "The quick brown" out of the sentence "The quick brown fox." The underlying HTML may look like this <tag>The quick brown fox.</tag>. Therefore, your selection (if you use txtrange.htmltext) should appear as <tag>The quick brown, but oh no, it actually appears as <tag>The quick brown</tag>. This is because the .htmltext property follows some kind of compliance rules that demans the text always be captured as valid HTML. Now, you can see why the selected text string never matches if you search for that string in the source document. Okay, so I will use .text instead. After all, if you append tags in HTML, as long as they are complete and correct, you can insert them just about anywhere without negatively altering the document. Well, here's something interesting. Sometimes, the .text string is not recognized. Imagine it like this... you highlight some text on a webpage, again "The quick brown fox" for example, then you open that webpage in notepad and do a search for that very text. Only you get a message that the text cannot be found. So then, you manually find the text in the document. It looks the same so you even paste the original text you copied into the document on a line right above or below the source text. Again, they look identicle, character for character, but the find dialog in notepad doesn't recognize the text you copied from the page. That is very frustrating and seems to make using something like streamwriter very unreliable. Therefore, if someone can recommend a way to search for a string in a text document and replace that string that they know is 100% effective, I would be grateful to hear of it. I will post the results of my test of the code above when I have tested it. Thanks all for looking. -gk
-
Okay, I may have the truncation problem solved. How about this... I have a textrange object, created by the user. It looks like this: meone.....goodb The first word should be someone and the last word should be goodbye with however many words in between. How can I fix this textrange to include the first and last words in their entirety? This is very general and should not be dependant on my code. However, I will let you know that the textrange object was declared as Dim TxtRange2 As mshtml.IHTMLTxtRange = Iselect2.createRange(). Thanks. -gk
-
All, I have a textrange object. I would like to add the textrange.text to a textbox, but I would like to limit the textrange to 100 characters. If the text is over a hundred, I would like to include the last word closest to 100 and add "...". I got as far as: If TxtRange.text.length > 100 Then End if I've just started researching this, but I posted here in case someone could provide a quick answer. Thanks. -gk
-
Problem solved. Thanks for looking. -gk
-
Okay, but that begs the question. Do you save information and read information to the config file the same as you would a text file? By the way, I am using VB .net in VS 2005. I do not distinguish between the two. If asked, however, I would not say that I am specifically using the .net architecture. -gk-
-
Hello, I can obtain the value/text of a splitbutton dropdown menu item by: toolstripbutton1.dropdownitems(0).text Can someone help me obtain the value of the menu item a user has clicked at the time the user clicks it. A simple example would be to populate a textbox with the value/text or to assign the value to a variable. For some reason, this control appears to not use the same method as a standard dropdown. Using VS 2005 and VB .net. Thanks as always. -gk
-
Getting highlighted text in a WebBrowser control has also been solved. Please consider this thread closed. -gk
-
I have read that it is not recommended to edit the config file. I figured I would use an .ini file type format, but I still need to know how to read the delimited text, under multiple headings. Would editing the config file not follow the same principles? It turns out though, that my apprehension at using the registry (Microsoft's preferred method) may not be well founded and I may go that route. Regardless, if someone can help with reading data from a text file under multiple headings, I would be grateful. That said, I am more interested in how to obtain the item value of a splitbutton dropdown menu. Because that does not apply to this thread, I will start another. I will still check here for any posted solutions on how to read the data from a text file. Thanks to everyone who has responded. -gk
-
Hello med, Thank you for the response and the code. It took me a second to get that I had to add an import statement to the MS VB fileIO namespace. Kind of silly. The code worked great!!! I guess I should clarify, I know how to write text to a file in its simplest form. I thought that might be enough, but then I realized that I am going to need to separate my data, probably under headings of some sort. I suppose I'm looking at having a kind of settings/configuration file in order to populate multiple fields. Any thoughts on that are welcome. I do have another question, however. I have observed that a combobox (maybe... one of the dropdown boxes anyway) can have a property of .selectedvalue. It seems that the toolstrip splitbutton does not. I can access the text of a specific menu item by using toolstripbutton1.dropdownitems(0).text, but I need to get the text of the menu item that is pressed by the user. If you can help with that, I would also be grateful. To answer your question, the reason that I need to write dropdown values and then load them is because they are not hard coded. Obviously, when the application closes any values that were added disappear. In this app, the user will be given the ability to access certain functionality/objects and to have those items placed in a shortcuts list (so to speak). It could be a dropdown, a list button, whatever. Right now, I'm just using a splitbutton to get it all together. An example would be changing the color of the form background and saving it (I would rather not use the registry). That example is simplistic, but you get the idea. The user will also have the ability to delete these values. I expect I should be able to use the replace function to edit the text file, or rather, I hope. We'll see when I get there. That's pretty much it. It's just a small piece of the puzzle, but to this point has been the most complex for me. Anyway, thanks for the help and I hope you can help with the remaining questions. -gk
-
Hello, I've been searching high and low for this answer, but not having any luck. Can someone provide a simple example (VB .net) of saving a value to a text file, populating the dropdown menu with that value, and then reloading that value from the text file when the application is closed and restarted? This code can be executed by clicking a button on a blank form with a splitbutton. Separately, I know how to add items to the splitbutton control, and how to write text to a text file. However, I do not know how to write data in the necessary format to a text file for a dropdown control or how to call/retrieve that information in the form load event. Please help. A simple example will work. As always, thanks in advance. -gk
-
Yeah, the problem is the frame(s). I discovered this bit of code: Dim variable As HtmlDocument Dim variable2 as HtmlElement variable = WebBrowser1.Document.Window.Frames(2).Document variable2 = variable.GetElementById("element") variable2.setAttribute("value", "test text") This works with .invokeMember also... So, this answers the question that I originally had and hopefully will pave the way for my using .invokeScript now that I know that I have to identify the frame where these actions are taking place. If someone can provide some insight on how to obtain the highlighted text in an HTML page hosted in a WebBrowser control and add that text to a text box on the form (preferably without using javascript, but any solution will do), I would be grateful. Thanks for looking. -gk
-
Hello, I'm hoping someone can help. I have an html document with three frames, topFrame, middleFrame, and bottomFrame. I have the document loading in a webBrowser control in VB .net 2005. I have a button on my form and when the button is clicked, I want to add text to a text box in the bottom frame. All documentation on MSDN and what I have found online shows that the following simple code should work, but I get an error message when the button is clicked. Please help if you can. Here is the code I am trying to execute: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hElement As HtmlElement = WebBrowser1.Document.GetElementById("parent.bottomFrame.document.getElementById('text')") hElement.SetAttribute("value", "test") End Sub The error (NullReferenceException was Unhandled) that is displayed has to do with the .SetAttribute line. Thanks in advance. -gk
-
I need to get the word the cursor is over in a vb .net richtextbox. Can anyone here help with this? Thanks. gkiril
-
Is there a way to have vb .net webbrowser statusbar display the text as the internet explorer statusbar would? I know how to display the url with .location or .locationname, but I want the status bar to display links, actions, etc. Any help would be greatly appreciated. gkiril