Comatose 290 Taboo Programmer Team Colleague

Sorry about that, up at the very top you need to add imports system.io (just above "public class").

Comatose 290 Taboo Programmer Team Colleague

it seems your AddToListBox procedure doesn't do anything.

Private Sub AddToListBox(ByVal barcode As String, ByVal item As String, ByVal price As String)
     list1.additem(barcode & "     " & item & "     " & price)
End Sub
Comatose 290 Taboo Programmer Team Colleague

First problem: you didn't use code tags. you can do that by typing (without the added spaces):
[ code=vb ]
' your vb code here
[ /code ]

Second Problem: it seems you are closing your file two times, but only opening it once... Tsk, Tsk.

Lastly, it seems that UPDATE is not the right word.... I think you mean "append", where it will write 1 line... then again another line. UPDATE would mean you are changing something already in the file.... here you simply want to add something to the file (or am I mistaken)? For this, you would probably want:

Private Sub cmdUpdate_Click()
Dim ndx As Byte
Dim tmp As String

Open App.Path & "\data.txt" For APPEND As #1 ' // yeah, for append
     Write #1, txtname, txtaddress, txtphone.Text
Close #1

lstcontact.RemoveItem (lstcontact.ListIndex)
lstcontact.AddItem (Chr(34) & txtname & Chr(34) & "," & Chr(34) & txtaddress & Chr(34) & "," & Chr(34) & txtphone & Chr(34))

End Sub
Comatose 290 Taboo Programmer Team Colleague
Comatose 290 Taboo Programmer Team Colleague

An initializer list?

Comatose 290 Taboo Programmer Team Colleague

What happens when the exchange changes (like daily)?

Comatose 290 Taboo Programmer Team Colleague

LOL

Comatose 290 Taboo Programmer Team Colleague

Erm, you know this thread is like 2 years old?

Comatose 290 Taboo Programmer Team Colleague

I'll wager a bet that he means "The most efficient" means by which to add a value to all items in an array.

Comatose 290 Taboo Programmer Team Colleague

1) You shouldn't post in red. It doesn't alter our level of urgency, and actually annoys us. I know your reason was probably to distinguish between your code and your words, but see 3 for that.
2) Let's not post in all caps. Makes it seem like you are yelling at me, and that doesn't inspire me to be helpful.
3) Use Code Tags. when you post code, you can use them by typing (without the spaces between [ and ]):
[ code=c++ ]
// your code here
[ /code ]

Since I am fairly unsure about a number of things in your code (such as missing parenthesis, why you are adding 1 to i during your output, and whatever convinced you to use >>) however, if you are wanting to add a simple if statement, as in the one you mentioned above:

if (tinssold > 52) {
     tinprice *= 2; // multiply by two is doubled right?
}
Salem commented: Well said. It's still horrid even without the wax crayon colouring in. +26
Comatose 290 Taboo Programmer Team Colleague
Comatose 290 Taboo Programmer Team Colleague

Why can't you use a vector? It would be a lot less painful.

Comatose 290 Taboo Programmer Team Colleague

Nice Find.

Comatose 290 Taboo Programmer Team Colleague

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.

Comatose 290 Taboo Programmer Team Colleague

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 …

Comatose 290 Taboo Programmer Team Colleague

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.

Comatose 290 Taboo Programmer Team Colleague

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.

Comatose 290 Taboo Programmer Team Colleague

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....

Comatose 290 Taboo Programmer Team Colleague

Ideally, you should debug with every optimisation turned off.
Then you get to see the code do pretty much what you wrote it to do.

*Nods*

Comatose 290 Taboo Programmer Team Colleague
#include <iostream>

using namespace std;

int main()
{
    int empNum = 0;
    cout << "Enter A Number: "; cin >> empNum;

    for (int i=0; i < (int)empNum; i++) {
        cout << "Loop " << i << endl;
    }

    return 0;
}
Comatose 290 Taboo Programmer Team Colleague

Inline can be done if the compiler deems it necessary. What level of debugging / optimization do you have it set to?

Comatose 290 Taboo Programmer Team Colleague

I think you can put that directly in the sql query, without having to pull the date from VB (ie: NOW()) but, doing it the way you are doing it works fine for me in vb 2008 express edition. You might consider adding the () to the end of Now, OR replacing the & with +'s

Comatose 290 Taboo Programmer Team Colleague

http://www.devmaster.net/articles/openal-tutorials/lesson1.php is a good place to learn openAL (a library that is used for playing sounds with video games... handles 3d Sounds)

Comatose 290 Taboo Programmer Team Colleague

And The Problem Is.....?

Comatose 290 Taboo Programmer Team Colleague

sure, move the cout to outside the for loop.

int total = 0;
for (i = 0; i < 3; i++)
{
     total+=hours_run[i];
}
cout <<"\n"<<total;
Comatose 290 Taboo Programmer Team Colleague

:$ Oops.

Comatose 290 Taboo Programmer Team Colleague

"The only thing that interferes with my learning is my education.”
-=Al Einstein=-

Comatose 290 Taboo Programmer Team Colleague

The code works perfect for opening other EXE's.... does it open skype at all?

Comatose 290 Taboo Programmer Team Colleague

you can find here a Crystal Reports step by step help

http://vb.net-informations.com/crystal-report/vb.net_crystal_reports_tutorials.htm

yang.

Check the date that the last post was posted.... you think they need help with this NOW?

Comatose 290 Taboo Programmer Team Colleague

can any one help or tell me wher i went wrong..

1) You didn't start your own thread.
2) You didn't use code tags.
3) You didn't post which line is highlighted when it goes into debug

Comatose 290 Taboo Programmer Team Colleague

You could probably modify this and use it: http://www.daniweb.com/code/snippet220.html

Comatose 290 Taboo Programmer Team Colleague

That all depends on exactly what you need. A File handling program is a bit more complex than a specific issue. How much of the project do you have done, and what does the code look like?

Comatose 290 Taboo Programmer Team Colleague

What the code does, (at least, what it's supposed to do) is use winsock to connect to the web server. Then it sends an HTTP request header to the server, requesting the page found in path "/index.htm", so if the page was http://www.somesite.com/thisthing/my.txt, then that part would be "/thisthing/my.txt". Then, what the web site does, it check for that file. If the file does not exist, the first line that it responds with, is a 404 (in the response header). So, the code checks for a 404 on the first line returned. What you could consider doing, is doing a msgbox on parts(0) right by the if instr(1, parts(0), "404") line (just above it), and see what it's actual line is.

Comatose 290 Taboo Programmer Team Colleague

*Looking Disgusted, Picks Up The Phone And Calls Richard M. Stallman*

Comatose 290 Taboo Programmer Team Colleague

Note:Please use code tags when posting code. You can do this by typing [ code=vb ] (without spaces) put the code in, then end it with [ /code ] (also without spaces).

Comatose 290 Taboo Programmer Team Colleague

How about only making one post for your question?

Comatose 290 Taboo Programmer Team Colleague

Hi so something like:

if (line == "cout <<") {
   // change it to what i want it to do
 }

like that? I don't get the whole vector to file thing, sorry

no, something like:

for (int i=0; i < (int)somevec.size(); i++) {
     if (somevec[i].substr(0, 3) == "say") {
          cout << somevec[i].substr(4, somevec.size()) << endl;
     }
}

This won't work 100% as you want, but you'll see what I meant by stripping off the ( ) and " "

Why don't you try this:

#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	string x = "say(\"Hello World\")";

	if (x.substr(0, 3) == "say") {
		cout << x.substr(4, x.length());
	}

	return 0;
}
Comatose 290 Taboo Programmer Team Colleague
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_VSCROLL = &H115
Const SB_BOTTOM = 7

Private Sub Text1_Change()
SendMessage Text1.hwnd, WM_VSCROLL, SB_BOTTOM, 0
End Sub
Comatose 290 Taboo Programmer Team Colleague

He asked this three years ago... think he found the answer yet?

Comatose 290 Taboo Programmer Team Colleague

How 'bout you hurry up and get me my code....PLZ PPLZ!

Comatose 290 Taboo Programmer Team Colleague

In VBScript, Kill won't work. I don't think dir() works in VBScript either. If doing this in VB6 (compiled language) it is strongly recommended that you do NOT compare the result of dir with "". if dir("C:\MyText.txt") <> vbnullstring then is a much better method. Double quotes is what is known as a null string. It uses somewhere in the area of around 8 bytes. vbnullstring is a special constant that is built into VB6, that reduces the memory usage to like 1 byte. This isn't a very big deal for small apps with a couple of strings.... but when you get into recursion, or loops with string processing and checking, it will make a visible difference.

Comatose 290 Taboo Programmer Team Colleague

Fantastic. :)

Now just mark this thread as solved.

Comatose 290 Taboo Programmer Team Colleague

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.

Comatose 290 Taboo Programmer Team Colleague

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.

Comatose 290 Taboo Programmer Team Colleague

what you need to do, is make the C++ program open the text file (argv), then read the file into a vector. Then interpret each line..... so you would have to write code that mimics this basic code idea:

for (int i=0; i < (int)somevec.size(); i++) {
     if (somevec[i].substr(0, 3) == "say") {
          // Processes "say" function.  You'll Need To Parse
          // The parenthesis and the quotes off of the typed in
          // say function: ie: say("hello") need to strip ( ) and " "
     }
}
Comatose 290 Taboo Programmer Team Colleague
Dummy dum;
dum.setName(temp);
Comatose 290 Taboo Programmer Team Colleague

You still have to take into account that reading in a file has newlines. So, what if my sentence is nearing the end of the line, and I need to break it into the next line? If "word wrap" isn't used, but instead manual line breaks, sentences could be span on multiple lines :/

Comatose 290 Taboo Programmer Team Colleague

I'm pretty sure you are going to need some kind of graphic library (sdl probably will do) in order to do what you are talking about.

edit: maybe you'll need a physics engine too.... I vote newton.

Comatose 290 Taboo Programmer Team Colleague

Well, using VB6 it's really easy: if dir("c:\autoexec.bat", vbnormal) <> vbnullstring then kill "c:\autoexec.bat" . However, this becomes a little different in vbscript (and for some reason, a bit uglier).

dim filesys
Set filesys = WScript.CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("c:\somefile.txt") Then
   filesys.DeleteFile "c:\somefile.txt"
End If
Comatose 290 Taboo Programmer Team Colleague

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.