|
Hello everyone,
I have a little problem with VBScript.
I've written a script that copy the selected text of the current Internet Explorer Window when the user click on the button and it works well.
But in some computers with different security rights, it doesn't.
Here is my code :
' Create the Shell object
Set Wsh = WScript.CreateObject("WScript.Shell")
Wsh.SendKeys "^{c}" ' send Ctrl+C, copy to clipboard
Set IE = WScript.CreateObject("InternetExplorer.Application")
Dim Num
with IE
.navigate "about:blank"
Num = .document.parentwindow.clipboardData.getData ("text")
.quit
end with
I guess that a user needs to have special rights to create a shell in a script and execute a command...
So How can I get the selected without using a shell ?
A way could be to execute copy from the Window where the button was clicked... But How do I get the object of the "parent" window of the script ?
Is there some kind of WScript.Parent attribute ?
Thanks,
Jerome
|
|
|
|
|
Hi guys,
How can i create my own description of the method i defined in my class such that when i call this method a TOOLTIP will come out exposing the Description i wrote for that particular method. Just like the members of any class in any assembly. When you press period (.) the members will come out and a tooltip will be displayed categorically showing the signature, return type and purpose for this method.
Tnx a lot!
|
|
|
|
|
I already told you, you need a third party tool to do this in VB.NET. The VB.NET compiler currently does not support generating the XML file required. VBCommentor on GotDotNet.com is a great place to start if you want to do this! Or, you could rewrite your classes in C#...
VBCommentor on GotDotNet.com[^]
RageInTheMachine9532
|
|
|
|
|
Ah ok sorry i didn't noticed my previous post has replies already. Tnx a lot.
|
|
|
|
|
I have a file stream reader that looks for certain text in a text file and prints that to a file. The problem is it is printing the following line i am looking for instead of the line i want.
here is the code:
Dim sr As New StreamReader("c:\test.txt")
Dim sw As New StreamWriter("c:\did it work.txt")
Do Until sr.Peek() = -1
If sr.ReadLine.StartsWith("LIN") Then
sw.WriteLine(sr.ReadLine.ToString)
End If
Loop
sr.Close()
sw.Close()
Any help very much appreciated
|
|
|
|
|
Anonymous wrote:
Dim sr As New StreamReader("c:\test.txt")
Dim sw As New StreamWriter("c:\did it work.txt")
Do Until sr.Peek() = -1
If sr.ReadLine.StartsWith("LIN") Then
sw.WriteLine(sr.ReadLine.ToString)
End If
Loop
sr.Close()
sw.Close()
The problem is you told the StreamReader (sr) to read the next line when you went to write the line you just read. The code should read like this:
Dim sr As New StreamReader("c:\test.txt")
Dim sw As New StreamWriter("c:\did it work.txt")
Dim strLine As String
Do Until sr.Peek() = -1
strLine = sr.ReadLine()
If strLine.StartsWith("LIN") Then
sw.WriteLine(strLine)
End If
Loop
sr.Close()
sw.Close()
Also, calling .ToString on a String variable is unnecessary. ReadLine always returns a String...
RageInTheMachine9532
|
|
|
|
|
Is there any way(probably api) to know which words are occured most frequently in MSWord Documnet. I am developing add-in and want to get
the list of and number of occurence word before you save the document?
Thanks
Shinya
|
|
|
|
|
You'll have to write the code to build that table since Word doesn't track that kind of information. Word can probably return individual "word" objects and you can use those to build a key->value dictionary. If the word isn't in the dictionary, add it set it's value to one. If it is in the dictionary, increment it's value. When you're done counting words, convert the dictionary to a 2D array of values and sort it on the counts. You'll then have the most often used word at the top.
RageInTheMachine9532
|
|
|
|
|
I want to be able to create an html file through a vb program that I have writtin what is the eaysist way to do this??
|
|
|
|
|
You didn't supply enough information about what you want to do like what does the VB program, that you've written, DO? And what are you doing with the HTML file?
But since you asked...open a file for Output with the Open statement and use Print #<filenumber> statements to output the text that will make up the HTML file, then use Close to close the file...
RageInTheMachine9532
|
|
|
|
|
Well i am makeing a grading program for a teacher and i need to know how do output the grades and students id as an html so that he may post them on his web page i thought about what was stated earlyer but when you output a file i don't know how to change the file extenions so that it is an .html insted of a .dat or .txt
|
|
|
|
|
What do you mean by "changing the file extension"? Since your outputting the file from VB, you can make the file extension anything you want... Are you doing this in Excel or something else?
Well, first you have to have some code that you having problems with. Discussing design over a forum is notoriously difficult...
But, I'm assuming your doing this as a class project? I'm not going to write the code for you, and neither will anyone else here.
If you know HTML, you could start by putting together an HTML page with some phony data for mockup. You'll use this as a template when you write out your actual data. Basically, your program is going to output the HTML HEAD section, as plain text, then output a TABLE with all the header tags. When you get to outputting the data, you'll add the appropriate table row and detail tags with your data. Then you'll output the closing tags to your table and HTML body.
That's the hard way of doing it, but is simple in terms of HTML...
The easier way, but requiring a more in depth knowledge of HTML, XML and CSS, is to output an XML formatted version of all your data. You'll have to make up an HTML page that INCLUDES, as a seperate file, the XML data file with all your data formatted in whatever tags you wish to use, and a CSS file that contains the formatting to use for each of these tags. This is a FAR more flexible solution...
RageInTheMachine9532
|
|
|
|
|
Does anybody know how to run a scanner from vb.net. ex. have a button scan a image.
Thanks in advance
|
|
|
|
|
Hi
I have made a scanner program based on imgx www.imgx.net. They also have a Dot net version called dotimage.
Both solution is easy to use.
Good luck
Vilhelm Marstrand
|
|
|
|
|
Yah I had seen that at atalasoft.. I'm going to try that.. I had seen here on the site somebody had made a program to scan using twain.. Been looking at how they did it.
Thanks
Gerry
|
|
|
|
|
Hi,
Does anyone know if it is possible obtain the network usergroup of the currently logged on user? I want to use this as the basis for a security class in vb.net.
Thanks
|
|
|
|
|
Refer the msdn documentation for WindowsPrincipal.IsInRole method so that you can get some idea.
|
|
|
|
|
Hello,
I am new to vb.net and i am writing a billing application for a client. The application takes a bunch of raw numbers and does some filtering and calculations and puts time into different tables. The problem is that there are like 400,000 records of raw data. Now i put all the queries and calculations and filters in the onclick when the user hits the generate clean data button. The for is set up like this the user picks the month he wants to clean up by choosing the start date and enddate and then hits clean data button. My question is how can i make it go faster an I doing it wrong? It workes but it takes for ever like 20 mins and sometimes it freezes up. I will try and illistrate how i have it set up.
button_onclick
'first i get the raw data and up it into a new table
testdap.selectcommand.commandtext= "selece * form table"
for i=0 to dataset.table.row.count-1
cleandap.insertcommand.commandtext ="insert into cleantbl
(field1,field2,etc ) where (dataset.table.row(i).item("field1),etc)
I have like 17 of these actions where i get the data and put it in another table or clean it up and sometimes compare it to another table with thousands of records and if any two records match by account i put that row into another table. Well i hope you get the idea. I have all this being done when the user hits the button. Is there a better and fast way to do this, again i am know to .net and any help will be greatly appriciatied.
Thank you,
Santana
|
|
|
|
|
First, move your SQL statements to the SQL server so it can cache the execution plans for your statements. Second, I take it from your "Select * from table" that your returning all 400,000 rows?! No wonder it's taking forever... See if you can move some of this logic to SQL stored procedure and Trigger procedures so it can preprocess some of the data for you. If you have the server preprocess some of the data for you, you can improve the "apparent" speed of your application. Third, keep the number of records that SQL returns to your client to a minimum.
RageInTheMachine9532
|
|
|
|
|
Hi Santana
I think I can give you a hint in your problem.
Sometime ago I had to solve a problem where the app had to update one table from a file. The file contained approx. 400,000 records, and the app had to decide which are the new records, which need to be removed, and which to be updated.
Running it as a FOR loop would have taken ~11 hours. Running it using SQL cursors and FETCH NEXT SQL command - 7-8 hours. The following SQL stored proc it took 20 minutes:
tbl1 - table being modified
tbl2 - table which has all records from the file
[code]
UPDATE tbl1 set Inactive=1 where pID=@prid
UPDATE tbl1 SET Inactive = 0
FROM tbl2
WHERE tbl2.iID = tbl1.iID AND tbl1.pID = tbl2.pID
DELETE tbl2
FROM tbl1
WHERE tbl2.iID = tbl1.iID AND tbl1.pID = tbl2.pID
INSERT INTO tbl1 SELECT * FROM tbl2
DELETE FROM tbl2
[/code]
Hope this will help you.
Regards,
Serge (Logic Software)
|
|
|
|
|
I'm trying to create a project with an OLE connection to a Microsoft Access database. I don't see a choice for the Jet OLE DB provider as one of my choice in the wizard. Is that the right choice? How do I add it?
Thanks.
|
|
|
|
|
Simple, you don't...
The code you use to open a connection to the database does something like this:
Public Sub ConnectToAccess()
Dim conn As New System.Data.OleDb.OleDbConnection()
' TODO: Modify the connection string and include any
' additional required properties for your database.
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\Documents and Settings\username\My Documents\dbFile.mdb"
Try
conn.Open()
' Insert code to process data.
Catch ex As Exception
MessageBox.Show("Failed to connect to data source")
Finally
conn.Close()
End Try
End Sub
Look in the VS.NET help for OleDbConnection, OleDbDataAdapter, and OleDbCommand for much more detailed information.
RageInTheMachine9532
|
|
|
|
|
|
I have created a user control that encapsulates a DataGrid. The DataGrid contains some inherited visual column styles that allow for editing in a custom textbox, combocbox, etc. The DataGrid is bound to a dynamically created DataTable. The trouble is: When I Tab from column to column, it steps through one and into the next. When I set a breakpoint anywhere, it behaves itself.
I suspect this is a threading problem. Any Ideas???
Thanx
Greg
|
|
|
|
|
hiiii
i want that somebody give me code to get the RGB values from an image and show in edit boxes.
its a bit urgent plz
regards
tahir
|
|
|
|