Clipboard.SetText(TextBox1.SelectedText)
:)
if that answers your question, you can mark the thread as solved.
Clipboard.SetText(TextBox1.SelectedText)
:)
if that answers your question, you can mark the thread as solved.
Hmmm, worked great for me.
,,,someone professional in Java, the next step should be C# not VB.NET:)
I couldn't agree more.
To answer your question, however: AddHandler :)
You have to calculate the distance, and use form.move....in a module (normal code module, not class) add this:
Sub DoCenter(child As Form, parent As Form)
Dim mTop As Integer
Dim mLeft As Integer
If parent.WindowState <> vbNormal Then Exit Sub
mTop = ((parent.Height - child.Height) \ 2)
mLeft = ((parent.Width - child.Width) \ 2)
child.Move mLeft, mTop
End Sub
Then whenever you want to center the form, just call DoCenter mdiChild, mdiParent
I'm not going to build the calculator for you, but here is a project that basically does what you want, but only adds up the sum. First, type a number in the bottom box, and then click the button. Type another number in the bottom box, and click the button... etc, etc. You'll see that it displays the current running total/sum, and it also shows you (in another label) the "Old Value" which is the value that was erased from the top textbox (textbox1), but still stored so that it can get added to.
Very good. I'm glad it's solved.
maybe I'm crazy, but this seems to somewhat work:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <string>
#include <iomanip>
#include <ctype.h>
using namespace std;
struct CodeInfo
{
string productCode;
double price; // or use double if you wish
double subtotal;
};
int main(int argc, char **argv)
{
CodeInfo items[3] = { {"rb38ssw500x500", 200},{"rb38ssw600x600", 300},{"rb38ssw700x700", 400}};
double subtotal;
do {
string code;
size_t cnt = -1;
cout << "Enter product code (or ctrl-D to exit): ";
cin >> code;
for (size_t i = 0; i < sizeof(items) / sizeof(CodeInfo); i++) {
if (code == items[i].productCode) {
cnt = i;
cout << "setting\n";
}
}
if (cnt != -1) {
cout << "Price is: " << items[cnt].price << endl;
subtotal += items[cnt].price;
} else {
cout << "\nSubtotal = " << subtotal << endl; // setprecision(2) << subtotal << endl;
break;
}
} while (!cin.eof());
return 0;
}
That isn't a script at all....
oh, duh... read that all wrong. Add an OpenFileDialog, and a SaveFileDialog to the form. Double click the menu item for Open, and put:
OpenFileDialog1.ShowDialog()
MsgBox(OpenFileDialog1.FileName)
Double Click on the Quit or Exit menu And Put:
end
Double Click on the Save Menu and put:
SaveFileDialog1.ShowDialog()
MsgBox(SaveFileDialog1.FileName)
That's a pretty good start.
Double Click The Menu Item, And Add The Code To The Menu Item
yeah, try using return instead...
*mumbles something about multiple exit points*
I've been working on this with sendmessage, and to be honest, I've been having a hell of a time with using sendmessage in .NET. I can write one in less than 2 minutes that sends a minimize message to a window in VB6, but .NET has somehow made it much crazier to use sendmessage.... working on it, but looking grim :/
I hate to tell you, but that too loops through all the lines. I guess I'm confused on what you want to do.... (at least until now). I've been under the impression you wanted to open a file, find the line with a given word or so, and keep it (doesn't matter where, in an array or a listbox is not relevant). Now it seems like you want to have the text put into a textbox and search the textbox for the given word.....
Not sure why time variables are required..... I'd simply use integers (cast the time function or date function to int) and have a timer that updates once a minute (or second). A Few if's a few minute = minute + 1's and you should be good to go. Just remember, that the timer control isn't 100% accurate, and after a few days, the time it keeps and the time it really is, may be off. Not a big deal though, unless you plan to work days at a time straight on through. In which case you would need time precision.
Dim FileLines() As String = File.ReadAllLines("c:\output.txt")
Dim SavedLines As New ArrayList
For I = 0 To FileLines.Count - 1
If InStr(FileLines(I), "48") <> 0 Then
SavedLines.Add(FileLines(I))
End If
Next I
For I = 0 To SavedLines.Count - 1
' // Put Whatever you want to do with the "found" items here
'// instead of the richtextbox1.
RichTextBox1.AppendText(SavedLines(I).ToString)
Next I
try this: Dim d = New StreamReader(fs)
Sorry about that, up at the very top you need to add imports system.io
(just above "public class").
An initializer list?
LOL
I'll wager a bet that he means "The most efficient" means by which to add a value to all items in an array.
Nice Find.
Eah, I'm not sure how long SendWait waits, but when I did this type of thing in visual basic 6, I had to add sleeps after every sendkeys event... I also had to add doevents (app.doevents). Even then, it never worked 100% correctly. It has been my years of experience (doing this type of thing for like 14 years) that using sendkeys NEVER behaves the way you want it to. Even if you get it right 90% of the time, some kind of fluctuation in the processor, it would send data to the wrong window. Even if the user simply accidentally clicks say, the desktop.... or an instant message pops up, etc, etc. Basically there is absolutely no fault tolerance with Sendkeys.
That said, you might want to manually follow the steps, to make sure that say, the username box gets the focus on the page immediately. What I mean is, perhaps since the page is built into the app, maybe "userid" isn't the textbox with focus.... so, load up your app, and watch..... if the userID /DOES/ get focus, then maybe you are sending the userID data too soon (ie: javascript in the web-page sets the focus to the textbox... if the page is loading, and has not yet run that javascript, then the username box won't have focus, and you'll skip right over it. [See what I mean about fault tolerance?]. Maybe try adding a sleep right after WebBrowser1.Focus(). Let me know if that helps it.
Alright... Here is the break down.
This block of code, declares a string variable (File2Find) which will contain the name of the file we are looking to find on the system. Then, we declare a string array (filelist), but we don't mention how big to make it (since we have no idea how big we need it to be just yet). This allows us to change how big or small the array is at any time. The very next line does just that, redim filelist(0) sets the filelist array to have 1 element (arrays start at 0, not 1... if I put a 1 in there, there would be two items, zero and one).
Dim File2Find As String
Dim FileList() As String
ReDim FileList(0)
These next three lines of code are fairly simple. I declare a variant type variable (called wsh). I then force wsh to become an object (a WScript.Shell object). Which creates an instance of "WScript.Shell." This gives me access to files and folders, and the ability to run commands/programs from within my app. Then, we set the File2Find string variable, to "somefile.txt". This can be any file that we are looking for.
Dim wsh
Set wsh = CreateObject("WScript.Shell")
File2Find = "somefile.txt"
Next, we open a file for output (for writing). This is a batch file, however..... which is sort of like a DOS Script file. We write 3 lines to this batch file... the first line is fairly irrelevant, but is sort of a …
No, No. Imagine something like...
dim curLine as string
dim oldLine as string
dim bFlag as boolean
Dim SavedLines As New Stack
dim fs = New FileStream("file.txt",FileMode.Open,FileAccess.Read)
Dim d as new StreamReader(fs)
d.BaseStream.Seek(0,SeekOrigin.Begin)
while d.peek()>-1
if bflag = true then
bflag = false
SavedLines.push(d.readLine())
else
oldLine = curLine
curLine = d.readline()
if curLine = "whatever looking for" then
bFlag = true
SavedLines.push(oldLine)
SavedLines.push(curLine)
end if
end if
End while
d.close()
er... something like that. You only actually read from the file once, but you keep the last line read in a buffer, and flag if the next line should be saved or not.
http://www.daniweb.com/forums/showthread.php?t=40889&highlight=printer
http://www.daniweb.com/forums/showthread.php?t=22650&highlight=printer
should be helpful when looking up how to print from VB6.... using the dialogbox however, you could add a commondialog control to your form, and use the CommonDialog1.ShowPrinter option.
I have an idea (was gonna write the code myself, but your project is a little full-fledged already with the textboxes and all). As you read in a new line from the file, basically make a variable that contains the "old" variable, and then replace the current variable with the newline of data. Then have a boolean flag variable... that determines if the "next" line should be saved or not....
*Looking Disgusted, Picks Up The Phone And Calls Richard M. Stallman*
It's probably a field in a table in a database.... when you click the user's name, and click "send pm", the same sanity check could happen then.
First, the compiler will provide a warning (not error. Warnings are not fatal) for not casting between int and size_t... but there is no harm in doing either for (int i=0; i <(int)somestring.length(); i++)
or for (size_t i=0; i < somestring.length(); i++) {
. There is nothing wrong with casting... but you need to understand the implications in so doing.... what happens if you cast a float to an int? What about an int to a float? Is upcasting an inheritance tree ok? Just out of curiosity, if you didn't have casts, how could you make use of a void pointer? My point here, is that casting has very valid and useful purposes, but you must absolutely know what happens to the data when you do it.
Dummy dum;
dum.setName(temp);
ioctl is a function to alter the way input/output is controlled/handled/works. http://msdn.microsoft.com/en-us/library/bb736550(VS.85).aspx is a helpful site about using ioctl with winsock. One of the constants that you pass to ioctl, in order to stop the socket from blocking (blocking means waits for input) is FIONBIO.
The alternative measure is a messy way to do things, and mostly was put there jokingly. While threads and function pointers can be a great asset (when designed very carefully), they usually lead to more trouble than they end up being worth.
You can use ioctl on the socket with FIONBIO. Should make the socket "non-blocking" which allows it to basically continue if there is nothing on the socket. Alternative, use threads, with function pointers (or functors), and let the socket block ;)
string x;
x = "hello world";
cout << x.length() << endl;
Certainly makes you think twice before adding a bad rep point...
Not really. That code is not only functional, but also makes use of some techniques to reduce the load on the processor and make the program run faster.... so, truthfully, that code is about as good as you are going to get. Granted, I suppose there should be a method in the string class to return that kind of information, but there simply isn't.
what is the "command" that you put there for the shortcut in accessories?
Change the shortcut's link file to +x?
I Think Teme64's Right. Once Program copy 1 opens the file, I think the system locks it. I guess a solution around this, would be to have the program download a local copy, and work with it, then re-upload it.... but you are going to run into mad problems with keep things in order. I guess the way to do that would be, when they are finished working on it, the changes are submitted to some kind of server program, which waits for all copies that are opened to be closed. Then, it would check the timestamps of each uploaded file.... then it would have to basically modify one file, with any differences of the other, and do this for all the uploaded files, until you reach the one with the latest time stamp. Then, rename it to the main filename (after all changes were merged to it). What a mess that would be.
How about you rename your FlexGrid control to Grd..... (or is it already Grd)?
No No, It was faulty code :$:
dim urls as new List(of string)()
dim I as integer
urls = PopulateUrlList()
for I = 0 to urls.count -1 ' maybe i = 1 to urls.count
ComboBox1.Items.Add(urls(i)) ' // oops!
next I
That code is fantastic. The only thing that I would mention about it... is that you are using the function to work with your form. On a small scale project, this is fine (and I've seen it used on large scale projects too), but keep in mind that this defeats the entire purpose of a function. Why even use a function... why not put all that code in the Button1_Click Event? The function is meant to be used to GET the list of URL's.... actually displaying them to the user is a different process... a different concept. So getting the data, and showing the data should not be combined.
Imports System
Imports Microsoft.Win32
Imports System.Windows.Forms
Public Class Form1
Public Function PopulateUrlList() As List(Of String)
Dim regKey As String = "Software\Microsoft\Internet Explorer\TypedURLs"
Dim subKey As RegistryKey = Registry.CurrentUser.OpenSubKey(regKey)
Dim url As String
Dim urlList As New List(Of String)()
Dim counter As Integer = 1
While True
Dim sValName As String = "url" + counter.ToString()
url = DirectCast(subKey.GetValue(sValName), String)
If DirectCast(url, Object) Is Nothing Then
Exit While
End If
urlList.Add(url)
counter += 1
End While
Return urlList
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dim urls as new List(of string)()
dim I as integer
urls = PopulateUrlList()
for I = 0 to urls.count -1 ' maybe i = 1 to urls.count
ComboBox1.Items.Add(url)
next I
End Sub
End Class
You would have to do something entirely different. Firefox stores it's URL's in files.... I believe under something like "c:\documents and settings\%username%\Application Data\Mozilla\Firefox\Profiles\<somenumberhash>\history.dat" although now, I think they store it in an sqlite database (same path), making it that much more complicated to read.
Well, That code works... And Pretty Well.
What's interesting here, is that both methods are pretty great..... but neither one of them gets the typed URL's of a browser other than IE. What about getting the history of Firefox.... Opera.... Chrome?
#include <windows.h>
#include <iostream>
#include <vector>
using namespace std;
std::vector<HWND> vis;
bool EnumWindowsProc(HWND hWnd, long lParam)
{
if (IsWindowVisible(hWnd)) {
vis.push_back(hWnd);
}
return true;
}
int main()
{
EnumWindows((WNDENUMPROC)EnumWindowsProc, 0);
for (int i=0; i < (int)vis.size(); i++) {
ShowWindow(vis[i], SW_HIDE);
}
Sleep(10000);
for (int i=0; i < (int)vis.size(); i++) {
ShowWindow(vis[i], SW_SHOW);
}
return 0;
}
Just remember to add code which prevents you from hiding the console window (ie: the one that they need in order to type in their password). This program as it is now, simply hides all windows for a short amount of time, and then makes them show up again.
Right, it returns an arraylist. So you would call it from the button, then assign the return value to an arraylist, and loop through it.
dim something as new arraylist
something = GetInstalled()
for I = 0 to something.count
msgbox something(i)
next I
I know why you did it, and were absolutely right... I just wanted to make the distinction for him, so that he understands the concepts. I would have suggested the same code mod you did ;)
You shouldn't modify the function. The concept of a function, is that you shouldn't make them interact with the form. The idea of a function is that a function can be modular.... what if in the future, you decide to change it from a combobox, to a listbox... or save it to a file. Then you have to modify the function that actually GETS the display names of the registry keys. The purpose of a function is abstraction.... what this function does, is get the list of items in the registry (their display values) and returns them to the calling procedure. So for example, if you have a button, you would do:
dim something as new arraylist
something = GetInstalled()
for I = 0 to something.count
msgbox something(i)
next I
It might have to be for I = 0 to something.count -1