Jamblaster 15 Newbie Poster

I think I have the answer to this:

First you get a self proclaimed expert who says it is absolutely wrong to ask for other people to write code for you (a la iamthewee) in this discussion here--> http://www.daniweb.com/software-development/cpp/threads/467572/question-a-car-class

Then you find this self proclaimed expert begging for other people to give them code here--> http://www.daniweb.com/software-development/cpp/threads/144681/way-to-do-this

Generally speaking, whenever you find a narcissist who thinks they know it all and claims to be an expert you also find a hypocrite with an amoral personality.

Personally my experience is that the less you know the more you are capable of learning.

With "Experts" like these on this site it isn't surprising to me that honest people with actual good intentions (more than just to propagate their own fantasies of grandiose and or superior intellect) who offer help on here are branded as unhelpful and verbally chastised by those same "Experts".

Just wanted to let everyone know on here that these so-called experts aren't always what they appear to be and anyone who would ask for code and then tell others who would do the same thing that they are bad or ignorant in some way isn't really an expert in anything at all except serving their own small self interests.

One final note is that this message about the experts on here (obviously) isn't aimed at any of the actually helpful people like ddanbe and ancient dragon (who I have seen many helpful comments by and found …

Jamblaster 15 Newbie Poster

I notice a lot of people on here only have negative and completely unproductive and unhelpful comments which have nothing to do with answering the question asked. I wish I was an expert at everything, but who was also a conceited and unhelpful person with a rude and ambiguously narcissistic personality, but I guess I'm not as lucky as some so I guess my advice isn't as good as some (who offer no advice at all, but negative and worthless comments). Anyway, it doesn't surprise me that posts sit on the top page here for days because of the helpful people who like to offer (non) advice and negative (worthless) commentary.

Jamblaster 15 Newbie Poster

I'm sure that when you get a job as a programmer your boss will be really glad that you know how to use Google, but I don't know how happy he's going to be that you can't write a program to save your life...

Jamblaster 15 Newbie Poster

What you really want to do is to use functions to perform your processing or classes (but function are really more appropriate here). The prototypes might look something like this:

void get_user_input(void);
void get_sum(int*, int*, int*);
void get_average(int*, int*, int*);
void get_product(int*, int*, int*);
void get_smallest_and_largest(int*, int*, int*);

You could declare some variables in main that might look like this:

int int_1 = int_2 = int_3 = 0;
int* ptr_1 = &int_1, ptr_2 = &int_2, ptr_3 = &int_3;

Then you could pass the pointers to each of the functions and use those functions and the pointers in the functions to sum (1 + 2 + 3), average((1 + 2 + 3) / 3), product (1 * 2 * 3), and get smallest and largest using if-else statements in that functions. Basically, the best way to break up any problem, big or small, (as noted above) is one step at a time--and in C++ the best way to do this is through classes or functions and so the best way to solve this problem (in my opinion anyway) is to go ahead and break it up into small pieces which are really simple to understand and write. You don't absolutely have to use pointers, but they are a great way to pass variable values back and forth while using relatively small amounts of memory (which is good). Anyway, that's just what I would do and when you get used to breaking a problem into functions it makes …

Jamblaster 15 Newbie Poster

My opinion is that you can never, ever have too many program comments or step comments and a program with too many comments is much easier to debug, use, understand and share than one with not enough comments. And just FYI, the poster here was asking for some help understanding about a simple C++ class so (obviously) it would help him to have too many rather than too few comments to explain the code; right? I always write too many comments in all my code and that way I can always go back and find and change something easily by finding a line of code or by looking for what it does with <Ctrl + F>. Anyway, if you don't think comments are good then that is a great opinion for you, but for me I like to have as many comments as possible because I don't believe that such a thing exists as a program with too many comments.

Jamblaster 15 Newbie Poster

When using cin and cin.getline() together the order is important because the '\n' character can sometimes make input skip. Here is a simple example of how you could use them together in the right order and with clearing '\n' so it doesn't get in the way:

#include "stdafx.h"
#include <iostream>
#include <string>
#include <conio.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{


    char name[50];
    cout << endl << endl << "Enter Your First Name: ";
    cin >> name;

    cout << endl << endl << "You entered: ";
    for(unsigned short x =0; x < (strlen(name)); x++){
        cout << name[x];
    }


    string buffer;
    cout << endl << endl << "Press Enter to Continue...";
    getline(cin, buffer);
    cin.get(); // clear '\n' now


    string name2;
    cout << endl << endl << "Enter Someone Else's Name: ";
    cin >> name2;

    cout << endl << endl << "You entered: " << name2;


    cout << endl << endl;
    cout << endl << endl << "Press enter to continue";
    char c = _getch();
    return 0;

}
Jamblaster 15 Newbie Poster

The first thing that I would suggest is for you to use some comments stating what everything is and what is is supposed to do and maybe some pre and post condition statements around the class methods. Look, I don't want to do your assignment or anything, but here is a different class which you can look at and (maybe) learn something from about how you might be able to write a C++ class of your own. The process is really pretty straight forward for many things. You define the class in the class definition and you declare the instance variables and the methods. After that you define the methods just like any other C++ user-defined method with the exception of using this syntax--> ClassName::MethodName(); You have to resolve the method to the class. You could alternatively just define the method within the class after its declaration, but that would leave you with a cluttered mess for a class definition (at least in my opinion). Anyway, below you will find a very simple C++ class that you can look at and see how to implement methods, constructors, destructors and copy constructors--this is just the tip of the iceberg though and there is a whole lot more so if you really want to learn then you should get a book or two and read up on it.

// Apartment.cpp : Defines the entry point for the console application.
//
// An Example C++ class that defines an Apartment in some …
Jamblaster 15 Newbie Poster

echo ("<b>Your Total Income is $dtotal</b>"); <!--here you have a typo-->

$dtotal is undefined, $total is defined. If you fix that one typo it might fix the problem.

Jamblaster 15 Newbie Poster

Ok, I have solved the problem. Thanks to everyone who offered advice, but I had to solve it myself (and that is always the best way isn't it?). If you run into the problem I had where you're running Windows and Apache and PHP then you can solve the problem of PHP executing executables being blocked by the Interactive Services Detection pop up (and run in the background as session 0 or whatever) you can solve the issue by uninstalling Apache as a service and running it as an app under an administrator's account. I don't know what implications this has on security, but I can tell you that if you run it as an app under an admin you will be able to run executables from within PHP scripts. Once again thank you to everyone for your helpful hints, but I guess this problem is one that you can only solve by being there and putting in enough research.

One important note is that if you are running Apache and PHP under Xampp then you can uninstall Apache as a service by just unchecking the green checkmark next to Apache on the Xampp control panel. Thanks to everyone again.

cereal commented: thanks for sharing your solution +11
Jamblaster 15 Newbie Poster

Ok, here is what I see. I see that you have worked hard on developing this program,but there is something I don't understand. In your function--> int openFile(File1, File2, File3) I see that you test if 3 files were open after the function returns to main, but what I see in the function is you returning a BOOL (true) when the function is supposed to return an integer (isn't it?). Try this: each time you successfully open a file in the openFiles() you could add one to an accumulator if(success) or keep the accumulator at whatever it was at(declare it as 0 at the top somewhere) and then return that accumulator at the end of the function. To be direct about it, the variable open will never, ever be == 3 if the function returning value to that variable doesn't accumulate anything and just returns true. Maybe I'm missing something, but I think that might be a problem.

Jamblaster 15 Newbie Poster

Once again, thank you for the advice, but as one of the posts above states, I have studied the PHP manuals and multiple other sources and do have PHP executing an executable already, but what is happening is that the Windows Interactive Services Detection Service pops up every time and the executable is the message it shows me when I click on 'view the message'. Here is my configurations: In Services.msc I have Apache running on: Local System Account and I have allowed it to interact with the desktop.

Here are some of the lines of code which (all) end up with a forced Interactive Services Interaction:

As you can see, I have gotten exec(), system() and passthru() to work, but all end up with the same problem. The problem is that the executable won't pop up to the desktop, but instead the Interactive Services Detection pops up. If I disable this service then nothing pops up. What I want to know is if anyone can tell me how to get PHP to execute a program on Windows in the foreground and not the background? I have been doing some more researching and think it might have something to do with Apache being installed as a service--any advice on that?

//exec('notepad.exe');
//system('Psexec.exe -i -d notepad.exe');
//exec("Psexec.exe -i -d  notepad.exe");
//passthru("notepad.exe", $results);
Jamblaster 15 Newbie Poster

If you have a working SMTP email server installed on your web-server then you can use a simple PHP function to send mail:

mail($to, $subject, $body, $headers);

Headers are optional, but if you want to use them you prepare the $headers variable like this:

$headers = "From: Example@Email.com \r\n";
$headers.= "CC: Exampl3@Email.com \r\n";

Each header needs to use both \r and \n to work correctly.

To prepare the body nicely you can prepare it like this before sending it:

$body = wordwrap($body, 70);

You can collect any or all of these variables through an HTTP interface so you could send an email anywhere with any subject, body, headers,...

It would use the configured SMTP server for your web-server and it would send it through port 25.

jalpesh_007 commented: thanks a lot... +4
Jamblaster 15 Newbie Poster

I have tried adjusting the user and group using the httpd config file and using the Windows Services management console. Currently I can get PHP to run the executable,but every time I get a pop up from the Interactive Services Detection Service that tells me that a service has a message for me and that message is the running executable. I'm obviously missing some kind of configuration here. I don't even expect to find an answer on here because I searched this site's old posts and found 3 or 4 other posts exactly like this and none had a good answer or a solution for the OP--and the PHP manuals don't have any either. Does anyone have any advice for getting past the Interactive Services Detection pop-up?

Jamblaster 15 Newbie Poster

I can tell that you really are trying to learn here and if you want to learn read and think about what the Dragon above said about p not being an integer.

Below here you can find an altered version of your last post of code within a working for loop which takes in input and provides output. It is (obviously) just a piece of test code and it is intended for you to use to see a possible way that you could go about solving this particular problem. Check it out and try to understand why it works:

#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{

    int products;
    int p, y, x, z, a, b;
    int items[100]; // don't know how big to go
    int quant[100]; // don't know how big to go
    float price[100]; // don't know how big to go
    float subtotal = 0;
    int peices = 0;
    float net[100]; // don't know how big to go


    //some code here
    cout<<"How Many products do you want to purchase ? :";
    cin>>products;
    for(p=0,y=16,x=32,z=52,a=61,b=68;p<products;y++,p++) {

        cout << endl << endl << "Item Number Please: ";
        cin>>items[p];
        cout << endl << endl << "Quantity Please: ";
        cin>>quant[p];
        cout << endl << endl << "Price of Item Please: ";
        cin>>price[p];
        net[p]=price[p]*quant[p];
        cout << endl << endl << "Net price of " << quant[p] << " of item number " << items[p] << " is: " << net[p];
        cout << endl << endl << "The subtotal …
Jamblaster 15 Newbie Poster

Thank you for that advice, but I tried it and found out that my OS version (Windows 7 Home) doesn't allow piping values into runas. So, my question is the same as before still. One thing to note is that apparently PHP is starting the executable and it shows in task manager and it shows that it's running under the account I hard-coded into the vb-script (which is also the same user account I configured Apache to run under). I also configured Apache (though services.msc) to be able to interact with the desktop. My question now, I suppose, is why are these processes running in the background and why I get them to pop up for user use? Maybe I'm missing something like: do I have to configure something in PHP.ini or in httpd.ini for Apache to allow for executables to interface with users?

Here's how the code looks now and it starts the process, but as a background which cannot be accessed for some reason:

    //$results = array();
    //$results = exec('runas /user:Windows7-PC\James "notepad.exe"');
    $results = exec('Start C:\\xampp\\vbs_runas_script.vbs');
    echo $results; // prints out nothing
    echo "Done";  // prints out as soon as the background process begins
    // what am I missing? 
Jamblaster 15 Newbie Poster

What to do is to post the code here so people can view it instead of linking to external resources.

Jamblaster 15 Newbie Poster

Something like this maybe:

// right where you collect option the first time put this

cin >> option;
option = tolower(option);
while(option != 'c'){



} // right above return 0; you put this to close the while loop

I don't know if that is exactly what you're looking for, but it if you place it in the right place it will force the system to iterate through more than one of whatever you are processing. Like the comment above, I can't understand any instructor would every tell a student of C++ to not use functions or struct or objects becasue that is where the power of C++ really lies (at least in my opinion). Anyway, hope this helps.

Jamblaster 15 Newbie Poster

I have been reading about exec() and passthru() and system() and different ways to use these, but so far not one of them is working. The Closest I have gotten is to get a request from CMD printed up on the page and so I researched how to pass a password programmatically to PHP to fill in the password, but I haven't quite figured it out.

I have tried dozens of different ways to get any of the methods to work, but the closest I have come is with this:

echo exec('runas /user:<Computer>\<User> "notepad.exe"' );

I'm using notepad here becasue I want to learn how to start an executable from PHP and notepad seems like an easy starting place.

I found a vb script through my searches and it is supposed to be able to fill in passwords for the runas call, but I'm not sure how to call it using PHP so I decided to ask if anyone knows how to call a vb script from PHP and the method or syntax you would use?

Jamblaster 15 Newbie Poster

Yeah, I was mistaken. MySQL does do implicit conversions for numeric data. Anyway, if you want to have a unique constraint you can you it through the MySQL command line interface like this-->

Login using the root account or whatever account you administer with.

use <Database name>;

Alter Table ghee
Add Constraint unique_sno
unique (sno);

This would add a unique constraint (Acts like a PK) to your table and then PHP wouldn't be able to insert duplicates.

If you already have a PK or another constraint that might cause a problem then you could remove it like this:

Alter table ghee
Drop Key <whatever_the_constraint_name_is>;

To find a constraint name you can use this:

SELECT * FROM information_schema.table_constraints
WHERE table_schema = schema()
and table_name = 'ghee';

You could also use multiple columns for a primary key like this:

Alter Table ghee
Add Constraint unique_entry
unique(sno, pack, weight);

Basically though, I guess your problem is that you don't have a required constraint on your Db table to stop redundant data entries. Anyway good luck and sorry about the bad information before.

Jamblaster 15 Newbie Poster

The code from Bachov Vargese above is correct, except you don't use quotes around numeric input to databases and that is probably where the error came from: I took the quotes off from around the number 18 and that should fix it. With '18' you are telling SQL to look for a string which reads '18', but with 18 you are telling SQL to look for the number 18--big difference.

<?php
include("connect.php");
$check_insert_query = "SELECT * FROM ghee WHERE sno = 18"; // HERE
$check_insert_result = mysql_query($check_insert_query);
$num_rows = mysql_num_rows($check_insert_result);
if($num_rows>0) {
die ("<p>Current SNO=18 already exists</p>");
}
else {
$insert_query = "INSERT INTO ghee (sno,pack,weight) VALUES (18,'kk',80)";
$insertion_result = mysql_query($insert_query);
//check whether the data insertion was successful
if(!$insertion_result)
{
die("Sorry! Something went wrong.</p>");
}
else
{
echo "<p>Record saved successfully.</p>";
}
}
mysql_close();
?>
Jamblaster 15 Newbie Poster

If you want multiple radio buttons to work together (user can only select one at a time) then you have to give all of them the same name like so:

 print "<input type='radio' name='Choices' value='$value1'>".$value1."</input><br />";
$value2=$row['choiceB'];
print "<input type='radio' name='Choices' value='$value2'>".$value2."</input><br />";
$value3=$row['choiceC'];
print "<input type='radio' name='Choices' value='$value3'>".$value3."</input><br />";
$value4=$row['choiceD'];
print "<input type='radio' name='Choices' value='$value4'>".$value4."</input><br />";
Jamblaster 15 Newbie Poster

I know that I worked (and still do) very hard to learn how to code a program from requirements and I feel like some of the other posters above that people who REFUSE to even try to learn to write a simple program shouldn't be getting any kind of programming degree. The FizzBuzz comment was especially valid. What is the requirements of the program? You have to fill an array and then search that array for the number of elements greater than a search value...seriously, put the pencil to the paper or the fingers to the keys and think about what needs to be coded and write some code and then post it here and maybe you can get some help. Show that you want to learn and people will be MUCH more willing to help you.

Jamblaster 15 Newbie Poster

Just an observation...you do realize that a very useful and well defined string class already exists and you can include it in your program with #include <string> (if you want to use a string class...).

Jamblaster 15 Newbie Poster

I learned the basics from a book called Microsoft Visual Basic 2010 Comprehensive. It doesn't teach you anything really interesting, but it teaches you the important basics of using VB.NET within Visual Studio--so you could learn about both at the same time using that book.

Jamblaster 15 Newbie Poster

Most of the people on here could easily help you with this, but you need to show some initiative and actually write some code that we could look at and help you with. I don't know your level of skill, but this program is a very, very, simple one. Step 1--collect a valid number of rolls (an int?) Step 2--roll the dice and collect the statistics (an array of int?) Step 3--calculate statistics (number of 1's over total rolls = % of 1's which were rolled, for instance...) Step 4--User feedback of % of 1's, % of 2's, % of 3's...number of total rolls. Here's a clue: each step can be implemented as a function. Implement the logic in a logical way: collect the input, do the processing and then provide the output...

Like I said though, if you come up with some code people will be a lot more likely to offer you some advice, but we aren't getting paid to do your work for you so we don't have any incentive to just write a program for you do we?

Jamblaster 15 Newbie Poster

Not to be judgemental or anything, but this subject interested me so I did a short search on it and I found multiple ways using system information files and registry techniques to do just this thing--and it took me maybe a couple minutes to find the information...

I can tell you this though. If you want to use a program to hide a file from a user you could change the attributes of it like this: (this is an about.txt file in the installation directory, for instance)

IO.File.SetAttributes(Application.StartupPath + "\Resources\About.txt", IO.FileAttributes.ReadOnly = 1) 'ReadOnly = 1 makes the file -s (SYSTEM) and -h (HIDDEN) so it would not be easy to find.

Anyway, to use an application to hide itself is an interesting thing, but you would have to design it to run with administrative privileges and that is another subject altogether (I think).

And, FYI, I am pretty sure that VB.Net is verbose enough to accomplish something like this if you know the right code and put in enough time and effort into finding your solution. Hopefully you don't want to do this for negative reasons, but, either way, it should be a fun learning process.

Jamblaster 15 Newbie Poster

You need to add a variable to hold a temporary best score with a default value and then test against that each iteration like this:

 #include <stdio.h>
 main() {   
    int GusNum,TotalNum,BesSor,a;
    char again;

    // a variable to hold the best score

    int BEST_SCORE = 10; // Variable to hold fewest tries (Best Score right?)

    // end of inserted code

    do
    { TotalNum=0;
    do
    {
    printf("Guess what the lucky number is <between 1 and 100>,then <Enter>:");
    scanf("%d",&GusNum);
    if(GusNum>=89&&GusNum<=100)
    printf("The number you typed is [%d] -Too LARGE,guess the lucky number again!\n\n",GusNum);
    else if (GusNum<=87&&GusNum>=1)
    printf("The number you typed is [%d] -Too SMALL,guess the lucky number again!\n\n",GusNum);
    else if(GusNum==88)
    printf("OK This is your LUCKY NUMBER [88] Well Done!\n");
    else
    printf("OUT OF THE RANGE \n");
    TotalNum++;
    }while(GusNum!=88);
    if(GusNum==88)
    {
    printf("Number of attempt [%d]\n\n",TotalNum);

    // what you need to add I think


    if(TotalNum < BEST_SCORE){
    BEST_SCORE = TotalNum; // set tries as new best score
    printf("Best Score so far is %d", TotalNum);
    printf("\n\n");
    }else{
    printf("Sorry, but the best score is: %d and you took %d tries...", BEST_SCORE, TotalNum);
    }


    // end of inserted code

    /*
    if(a>TotalNum)
    {
    printf("Best score so far [%d]\n",TotalNum);
    }else printf("Best score so far [%d]\n",a);
    the wrong part i want to set the best socre*/
    printf("Play again Type 'y' for YES; all other characters for NO:");
    scanf(" %c", &again);
    }
    }while(again=='y');

}
Jamblaster 15 Newbie Poster

For floor as Integer = 1 To MAX_FLOOR

MAX_FLOOR Doesn't have a value so that loop will never execute. You never set the value for MAX_FLOOR anywhere.

After this line--> richtextbox1 = InputBox("Enter the number of rooms occupied.", "Floor: " & intCount)

Place this line--> MAX_FLOOR += 1

Jamblaster 15 Newbie Poster

Your spaces are disapperaring because you aren't using an input method that grabs a whole line and stores it (like getline(cin, <string>), for instance). Maybe you could also just use the string class instead of C-strings because they make so much more sense and are so much more useful in actual programming--unless of course using a C-string is what you have to do, in which case you just need to adjust your input methods and possibly append a " " to the end of each C-string except for the last one. Just a thought.

And in response to the above poster, I totally agree and think you might want to try Visual Studio because it is a great (and free to use for students) all-in-one IDE for multiple languages.

Jamblaster 15 Newbie Poster

Read the exact specifications of the assignment--what has to be done (methods) what has to be tracked/stored (instance variables) and create the classes with the variables and the methods to perform the required processing. It looks to me that you are on the right track and all you really need is to carefully read and think about what the problem is asking. Maybe get out of a piece of paper and plan the design out very carefully and then code that design so as not to miss anything. The objects and methods required are right there in the requirements you listed and if you carefully write them out then you will be sure to get everything.

Jamblaster 15 Newbie Poster

Here's a hint at a simple way to print out multiple lines with different things using conditions. I didn't want to do the assignment for you--you have to figure out what to put in each for statement, but maybe this hint can help you see the basic structure you might be able to use.

for(){
        cout << endl;
        if(X == 0 || X == 1 || X == 2 || X == 6 || X == 7 || X == 8){
            for(){
                cout << " ";
            }
            for(){
                cout << "X";
            }
            for(){
                cout << " ";
            }
        }else{
            for(){
                cout << "X";
            }
        }
    }
Jamblaster 15 Newbie Poster

If you post your actual code it would make it a lot easier to understand what your problem might be.

Jamblaster 15 Newbie Poster

And here's a quick alteration I did to show how you could parse out spaces. You could use this same kind of technique to parse out anything you don't want as input:

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Dim num_len As Integer = 0 ' set by length of whole numbers
        Dim per_len As Integer = 0 ' set by length of decimal numbers

        Dim str_input As String = TextBox1.Text ' holds user input provided from MaskedInputBox
        Dim _Count As Integer = str_input.Length ' total provided input string length

        Dim str_number(_Count) As String  ' maybe the length is all whole numbers?
        Dim str_Decimal As String ' Same as above
        Dim str_Percent(_Count) As String ' maybe the length is all decimal numbers? Holds numbers after "." is found

        For X As Integer = 0 To _Count - 1  ' Parse the whole numbers out now


            If (str_input(X) <> "." And str_input(X) <> " ") Then  ' Parse the whole numbers and remove spaces then the decimal point

                str_number(X) = str_input(X)

            ElseIf (str_input(X) = ".") Then

                num_len = X ' whole numbers equals how many iterations before we found "."
                GoTo PARSE_POINT
            End If
            If (0 = 1) Then
PARSE_POINT:
                str_Decimal = str_input(X) ' 'parse the decimal point out now
                Dim dec_place As Integer = X ' the decimal point is found where the 'X' For stopped iterating to come here

                For Y As Integer = 0 To (_Count - (X + 1)) ' …
Jamblaster 15 Newbie Poster

Here is the solution to your problem. First, to solve the conundrum presented by DDanbe, you need to use a MaskedTextbox and set a custom mask using as many numbers and you want on the left then a decimal point and then as many as you want on the right. If you don't know how to do this then look it up. Next you have to parse the input from string to strings to numbers to number like so:

Notably, the code is ugly because I wrote it fast for an example, but it works (and that's what matters). Check it out and it will show you how to parse input to validate that you have a double and then use that double in some way (I used a msgbox to display it). Anyway, hope this helps.

  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Dim num_len As Integer = 0 ' set by length of whole numbers
        Dim per_len As Integer = 0 ' set by length of decimal numbers

        Dim A As Integer = 0 ' place holder

        Dim str_input As String = TextBox1.Text
        Dim _Count As Integer = str_input.Length

        Dim str_number(_Count) As String  ' I don't know big of a number you want to go up to
        Dim str_Decimal As String ' Same as above
        Dim str_Percent(_Count) As String ' Use this to hold numbers after the "."

        For X As Integer = 0 To _Count - 1  ' Parse the whole numbers …
Jamblaster 15 Newbie Poster

The myCommand.ExecuteNonQuery() line is what updates the database. This event handler is pretty small. Have you tried debugging it with breakpoints line by line and watching what happens at each line. This might give you a better idea of where it gets off track.

Jamblaster 15 Newbie Poster

I'm not sure exactly what you're asking, but if you wanted to click a button with a sub procedure or function or another event handler, or whatever, then you need to use the Object.PerformClick() procedure. Let's say that you have a button called btnStart and you want it to click when your form loads. In your form load event handler you would place this--> btnStart.PerformClick()

I hope that helps.

Jamblaster 15 Newbie Poster

To find the desktop you could use the my namespace.

My.Computer.FileSystem.SpecialDirectories.Desktop
Jamblaster 15 Newbie Poster

You have nothing wrong with your code that I can find. I copy/pasted your code and changed the connection string to connect to .accdb instead of .mdb and it ran perfectly. I created quick test Db and a windows form with just the 1 button and it ran. Below is the working code as it worked on my machine less than 1 minute ago:

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Try
            Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;" & "Data Source= C:\TEST.accdb"
            Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
            Dim myUpdateQuery As String = "Update Navire_Clients set equipage = 'Skipper' where Num = 10"
            Dim myConnection As New OleDb.OleDbConnection(connectionString)
            Dim myCommand As New OleDb.OleDbCommand(myUpdateQuery)
            myCommand.Connection = myConnection
            myConnection.Open()
            myCommand.ExecuteNonQuery()
            myConnection.Close()
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try
    End Sub
End Class
Jamblaster 15 Newbie Poster

For something like this with a pre-determined number of guesses and a sentinel value (Correct guess exits) you would want to use a do-loop while(X <=10 And Correct = False) You would declare X prior to the loop as an Integer with a value of 0 and Correct prior to the loop as a Boolean with the value False. You would increment X += 1 at the bottom of the loop just above the Loop While statement. This is a really simple programming exercise and if you just concentrate on the logic going from top to bottom you shouldn't have any problems getting it right.

Jamblaster 15 Newbie Poster

I already scrapped that module and created a new class which loads the data into an array and then loads the array into a listbox and then uses data-linked objects to add and delete records with. It isn't pretty and it isn't directly programmatically controlled, but it works and I spent too much time debugging that one line of code already.

Jamblaster 15 Newbie Poster

I just commented out the ListBox removal line and then I added some lines to the try-catch routine. Below you can see what I put in. When I run the record deletion event handler it bypasses every one of the new catches and the system exception box pops up.

            Catch exception As ArgumentNullException
                MsgBox("ARGUMENT NULL EXCEPTION", 16, "ERROR")

            Catch exception As AccessViolationException
                MsgBox("ACCESS VIOLATION EXCEPTION", 16, "ERROR")

            Catch exception As AppDomainUnloadedException
                MsgBox("APP DOMAIN UNLOADED EXCEPTION", 16, "ERROR")

            Catch exception As ArgumentOutOfRangeException
                MsgBox("ARGUMENT OUT OF RANGE EXCEPTION", 16, "ERROR")

            Catch exception As DuplicateWaitObjectException
                MsgBox("DUPLICATE WAIT OBJECT EXCEPTION", 16, "ERROR")

            Catch exception As ArgumentException
                MsgBox("ARGUMENT EXCEPTION", 16, "ERROR")

            Catch exception As DivideByZeroException
                MsgBox("DIVIDE BY ZERO EXCEPTION", 16, "ERROR")

            Catch exception As ArithmeticException
                MsgBox("ARITHMETIC EXCEPTION", 16, "ERROR")

            Catch exception As ArrayTypeMismatchException
                MsgBox("ARRAY TYPE MISMATCH EXCEPTION", 16, "ERROR")

            Catch exception As DeletedRowInaccessibleException
                MsgBox("DELETED ROW INACCESSIBLE EXCEPTION", 16, "ERROR")

            Catch exception As DuplicateNameException
                MsgBox("DUPLICATE NAME EXCEPTION", 16, "ERROR")

            Catch exception As VersionNotFoundException
                MsgBox("VERSION NOT FOUND EXCEPTION", 16, "ERROR")

            Catch exception As DataException
                MsgBox("DATA EXCEPTION", 16, "ERROR")

            Catch exception As DataMisalignedException
                MsgBox("DATA MISALIGNED EXCEPTION", 16, "ERROR")

            Catch exception As DBConcurrencyException
                MsgBox("DB CONCURRENCY EXCEPTION", 16, "ERROR")

            Catch exception As ObjectDisposedException
                MsgBox("OBJECT DISPOSED EXCEPTION", 16, "ERROR")



            Catch exception As SystemException
                MsgBox("SYSTEM EXCEPTION", 16, "ERROR")
                Me.Close()
Jamblaster 15 Newbie Poster

Try this:

 Sub Main()
        Dim num As String

        num = InputBox("Please enter your number!!!", "What was the number you were given?").ToString()
        Dim len As Integer = num.Length()
        ' use not because isnumeric returns a 0 if the input is numeric which is a BOOL FALSE

        If (len = 12) Then
            If (Not (IsNumeric(num.Substring(0, 3)) And (num.Substring(3) = "-") And (Not (IsNumeric(num.Substring(4, 3)))) And (num.Substring(7) = "-") _
            And (Not (IsNumeric(num.Substring(8, 4)))))) Then


                MsgBox("You input a Phone number: " & num, MsgBoxStyle.Information, "Congratulations")

            End If

        End If

        If (len = 11) Then

            If (Not (IsNumeric(num.Substring(0, 3)) And (num.Substring(3) = "-") And (Not (IsNumeric(num.Substring(4, 2)))) And (num.Substring(6) = "-") _
            And (Not (IsNumeric(num.Substring(7, 4)))))) Then

                MsgBox("You input a SSN number: " & num, MsgBoxStyle.Information, "Congratulations")

            End If

        End If

        If (len = 13) Then
            If (((num(5) = "@") And (num(9) = ".") And (Not IsNumeric(num.Substring(10, 3))))) Then

                MsgBox("You input an E-mail address: " & num, MsgBoxStyle.Information, "Congratuations")

            End If

        End If

        If (len > 13 Or len < 11) Then
            MsgBox("Invalid input detected: " & num, MsgBoxStyle.Critical, "Sorry")
        Else
            ' the default statment
            MsgBox("Invalid input detected: " & num, MsgBoxStyle.Critical, "Sorry")

        End If

    End Sub
Jamblaster 15 Newbie Poster

I am having a problem getting this code to work in deleting records from a database. The path to the database is correct and I have another couple of event handlers that work fine using this same datbase so I know that the path to the Db is good. Any advice would be great, thanks. I marked where the error occurs at debugging. I know what line breaks the program, but I don't know why.

Private Sub radRemoveWords_Click(sender As System.Object, e As System.EventArgs) Handles radRemoveWords.Click


        Dim _intUpperBound As Integer = 1000 'dummy value
        Dim str_newWords(_intUpperBound) As String

        ' make the database connection to update the table

        Dim frmSpellingTest As New frmSpellingTest
        Dim _strFileLocation2 As String = frmSpellingTest._strFileLocation
        Dim _intUpperBound2 As Integer = frmSpellingTest._intUpperBound

        Try

            ' Array to use in handling incoming data from Db
            Dim strWords(_intUpperBound2) As String ' frmSpellingTest._intUpperBound

            ' SQL string to grab spelling words from the database table (argument 1 to data adapter creation)
            Dim strSQL As String = "SELECT * FROM spelling_list"
            ' User can supply location of word list (default will be displayed for ease of use)
            ' Path to the database table (argument 2 to data adapter creation)
            Dim location As String = _strFileLocation2
            Dim strPath As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;" & "Data Source=" & location
            ' Use the SQL statement and path to create a data adapter to database
            Dim odaSpellingList2 As New OleDb.OleDbDataAdapter(strSQL, strPath)
            ' Create an DataTable to hold the data retrieved
            Dim datWords As New DataTable
            ' Counter to …
Jamblaster 15 Newbie Poster

Just wondering if this is possible because I have been looking and haven't found a way to do this. I have found ways to create and save new Word documents, but I'm developing a program which opens, reads to a RichTextBox Object and then speak the text back. I have it working for .txt files, but I'm working on trying to get it to work for Word and Adobe documents too so if you have any advice that would be great thanks. This isn't for anything, but my personal use so any type of coding would work as there are no restrictions. Anyway I would appreciate any advice at all or a definitive answer that this isn't possible so I can forget it. Thanks.

Jamblaster 15 Newbie Poster

Thank you very much. I totally missed that. I appreciate you help figuring that out.

Jamblaster 15 Newbie Poster

If intTicketChoice = 0 Then
Select Case intSeatChoice
Case 0
_decTotalCost = intNumberOfTickets * _intSeasonBoxSeats
Case 1
_decTotalCost = intNumberOfTickets * _intSeasonLowerDeck
End Select
End If
If intTicketChoice = 1 Then
Select Case intSeatChoice
Case 0
_decTotalCost = intNumberOfTickets * _intSingleBoxSeats
Case 1
_decTotalCost = intNumberOfTickets * _intSingleLowerDeck
Case 2
_decTotalCost = intNumberOfTickets * _intSingleUpperDeck
Case 3
_decTotalCost = intNumberOfTickets * _intSingleStandingRoomOnly
End Select
End If

I thought that these lines--187 to 210 did that though. This is why I can't figure out why it says zero. I understand that _decTotalCost has a value of zero when it is displayed in _strTotalCost but These statements should have added value to that variable right?

Jamblaster 15 Newbie Poster

As you can see, I changed all the local variables--> decTotalCost to be a class variable--> _decTotalCost and I create a class variable --> _strTotalCost that uses the value of _decTotalCost to populate the text element of the feedback label and now it reads as $0.00 again when I run the application. I don't understand why it doesn't work and would like some assistance.

' Restrict uncoded data type changes (conversions)

Option Strict On

Public Class frmBaseballTicketSales

'Class variables (all Integers will be initialized as Integer Literals)
'                (the Decimal will be initialized as a Decimal Literal)


Private _intSeasonBoxSeats As Integer = 2500
Private _intSeasonLowerDeck As Integer = 1500
Private _intSingleBoxSeats As Integer = 55
Private _intSingleLowerDeck As Integer = 35
Private _intSingleUpperDeck As Integer = 25
Private _intSingleStandingRoomOnly As Integer = 15


Private _decTotalCost As Decimal = 0D


Private _strSeasonBoxSeats As String = "Box Seats $2500"
Private _strSeasonLowerDeck As String = "Lower Deck $1500"
Private _strSingleBoxSeats As String = "Box Seats $55"
Private _strSingleLowerDeck As String = "Lower Deck $35"
Private _strSingleUpperDeck As String = "Upper Deck $25"
Private _strSingleStandingRoomOnly As String = "Standing Room Only $15"
Private _strTotalCost As String = "The Total Cost of Tickets Purchased is: " & _decTotalCost.ToString("C")





Private Sub frmBaseballTicketSales_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' This code will execute when the program loads. It will display the opening
    ' SplashScreen for 5 seconds allowing the user to view the program information.

    Threading.Thread.Sleep(5000)

End Sub


Private Sub cboTicketChoice_SelectedIndexChanged(ByVal sender …
Jamblaster 15 Newbie Poster

Ok, here is my question. I got this code working (Yeah it isn't really complex I know, but I'm a beginner anyway) and I couldn't make it work when using a class variable for the strTotalCost and decTotalCost variables and passing decTotalCost to the strTotalCost to show the calculated price. Could anyone tell me why when I replaced the class/global variables with the local variables it worked? What was happening prior was the final price was displaying as $0 every time. I tried If Then statements and Select Case statements and some combinations of the two to do the calculations, but nothing worked until I used the local variables. I know that it makes it simpler (and in this case more sense) to use the local rather than class variables, but I would like to know why my attemp at using class decTotalPrice and strTotalPrice resulted in the lblTotalCost displaying $0 because I would like to learn from my mistakes. Thank you for any help you can give me.

' Restrict uncoded data type changes (conversions)

Option Strict On




Public Class frmBaseballTicketSales


    'Class variables (all Integers will be initialized as Integer Literals)
    '                (the Decimal will be initialized as a Decimal Literal)


    Private _intSeasonBoxSeats As Integer = 2500
    Private _intSeasonLowerDeck As Integer = 1500
    Private _intSingleBoxSeats As Integer = 55
    Private _intSingleLowerDeck As Integer = 35
    Private _intSingleUpperDeck As Integer = 25
    Private _intSingleStandingRoomOnly As Integer = 15
    Private _intSeatType As Integer = -1



    Private _strSeasonBoxSeats As String = …
Jamblaster 15 Newbie Poster

Thank you very much. I'm new to this obviously (like you can't tell LOL) and I really don't know why adding the new line onto line 33 fixed the problem, but it did. If it wouldn't be too much to ask could you explain why it fixed my problem because I don't understand. There is a new line escape sequence at the beginning of the line so why did not having one at the end create my problem? I was under the impression that one new line sequence would be enough for each line. I have never run into this particular problem before. Again thank you for debugging that for me because I couldn't see the problem for the life of me. Good catch on line 44 too, but for my compiler it does clear the screen so maybe we just have different compilers.

Jamblaster 15 Newbie Poster

I can't tell why this piece of code wont work, but another one which I wrote does because they look exactly the same to me. Please tell me if you can see what the difference is because I cannot. I tried using the code snippet thing, but it doesn't let you copy/paste and I'm not really interested in typing both out again right now.

First one:

#include <stdio.h>
#include <stdlib.h>

main()

{

  char cYesNo = '\0';
  int iResp1 = 0;
  int iResp2 = 0;
  int iResp3 = 0;
  int iElapsedTime = 0;
  int iCurrentTime = 0;
  int iRandomNum = 0;
  int i1 = 0;
  int i2 = 0;
  int i3 = 0;
  int iCounter = 0;
  int x = 0;


  srand(time(NULL));

  printf("\nPlay a game of Concentration? (y or n): ");
  scanf("%c", &cYesNo);

  if(cYesNo == 'Y' || cYesNo == 'y') {

    i1 = rand() % 100;
    i2 = rand() % 100;
    i3 = rand() % 100;

    printf("\nConcentrate on the numbers: %d %d %d", i1, i2, i3);


    iCurrentTime = time(NULL);

    do{

      iElapsedTime = time(NULL);

    } while ( (iElapsedTime - iCurrentTime) < 3);

    for(x=0;x<25;x++); {
      printf("\n\n\n");
    }//end for

    printf("Enter each number separated with a space: ");
    scanf("%d%d%d", &iResp1, &iResp2, &iResp3);

    if(i1 == iResp1 && i2 == iResp2 && i3 == iResp3)
      printf("\nCongratulations!!!");

    else
      printf("\nSorry you didn't get it correct");

}//end if

}//end main

Second one:

  int x = 0;
  char cYesNo = '\0';
  int iResponse1 = 0;
  int iResponse2 = 0;
  int iResponse3 = 0;
  int iElapsedTime = 0; …