Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I can't imagine that I/O wasn't one of the first things covered in whatever programming course you are taking but here is an example

    Dim text() = {"line 1", "line 2", "line 3"}

    Dim sw As New System.IO.StreamWriter("D:\output.txt")

    For Each line As String In text
        sw.WriteLine(line)
    Next

    sw.Close()
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Do it by hand and write down every step you had to do in order to get it done. Consider pseudo-code like the step-by-step instructions in a recipe.

One thing to consider for part 1.3 - is the answer to this the average of all the averages, or is it the average of all of the individual grades. It is possible that each student has a different number of grades to average so by averaging the averages you are weighting some students differently than others. I'm assuming there can be a different number of grades because the number of grades is entered at the start of every line rather than just once.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I have been having a problem for a few months with the video driver for my Dell laptop. The hardware/driver are from Intel. The driver from 2016-09-29 works just fine. It has a feature that I use regularly to rotate the display via hotkeys - very convenient for document reading. Unfortunately, all later drivers disable this feature. Also unfortunately, Windows Update keeps downloading and installing the latest driver. This means that I have to repeatedly re-install the old driver. Not a big problem but an unnecessary one in my opinion. After several iterations through Intel Support I was told (in my words), "It's not our problem. Here's the Microsoft Support URL". The Microsoft Support staff was very helpful in telling me how to disable automatic updates although I'll reserve judgment for a few weeks until I see how effective it was. If anyone is interested, here is how to disable auto update in Windows 10.

Go to the services control panel by running

services.msc

Set the Startup Type for Background Intelligent Transfer Service to Disabled then Stop the service.

Set the Startup Type for Windows Search to Manual.

Set the Startup Type for Windows Update to Manual (it may display as Manual (Trigger Start)).

I was told that by doing this I would still be able to get updates, but I would have the option of deciding which ones to apply (like I used to do in XP and W7). I left Intel with the comment:

Here's a novel …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That's the plus side, Jim?

Well, it's a plus when I get to camp and have a thousand and one things to take care of that piled up over the winter. It's not a plus when things settle down and I am looking for things to do. All in all, I'd much rather see a lot more posts with interesting question.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Looking at your data I interpret it as being lists of lists. Data Set 1 consists of two lists

A    
B C D

Data Set 2 consists of two lists

A Q C
B C D

So break your problem down. Instead of comparing two Data Sets you are comparing lists of lists. In pseudo code

Do until no more lists

    get list from Data Set 1
    get list from Data Set 2
    compare the lists

loop

To compare the lists you just step through both lists together (stopping when one list is exhausted) and compare elements at the same position. You can write a function that returns a list from a data set, or some value that indicates there are no more lists.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You had T-Shirts (and probably coffee mugs) and didn't tell me when I came to visit? Shame on you :-(

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

from the lack of activity on DW these days

On the plus side, I can be offline for several days (got to camp on Thrsday but had to wait until today to go to town and activate my internet & phone for the summer) and still get caught up with the backlog in 5-10 minutes max.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can win up to $55,000 to optimize NASA's Fluid Dynamics code. See the link for details.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I suspect the problem is with the field named E-mail. Either put delimeters around it like [E-mail] or, better yet, rename the field to email.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

pls design and develop a basic program dat converts minutes into days

Judging by your post it is possible that you have not read the Daniweb Posting Rules and Terms of Service. Please give these a read. You might also want to Read This Before Posting a Question

Here is a partial list of why I believe you haven't read the rules:

  • You didn't show any effort on your part.
  • You didn't ask for help. You just asked us to do your work for you.
  • You hijacked a 6-year-old thread.
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The advice was given as

Don't use double as Booleans.

Your question was

Why can't you use a double as a boolean ?

You weren't told that you couldn't. You were told, in effect, that you shouldn't. There's a big difference. You shouldn't run with scissors and you shouldn't use GOTOs, but you can if you want to (except for the GOTOs).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Folk that were chatting here may never come back to you.

Particularly Ancient Dragon.

We miss you Mel.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Only if you respond to it.

rproffitt commented: But you get +1. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you are going to revive a six-year-old thread at least try to squeeze in a verb.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I used to do that all the time. I wrote a large number of command line scripts to simplify network admin tasks. For example, adding a network printer to a workstation took me 15 seconds from the command line. Compare that to navigating through multiple GUI windows.

The only downside was that my boss wasn;t comfortable using the command line and didn't want me to do it. Since I was the only person in the group capable of doing the work I basically just ignored him.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

i tried. it says runtime error

Then you have your answer. Wouldn't that have been easier than asking us to do your work for you?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Show us the code.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You google "python convert string to integer" and pick one of the 536,000 results instead of asking someone here to do it for you.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Help you with it? yes. But we are not going to do it for you. Show us what you have so far.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@Subbu_2 - If you want to know when this issue is sorted out then I suggest you bookmark the thread and check on it periodically instead of putting the onus on the OP to contact you. Or, if you go to the first post in the thread and click on the push-pin (assuming you have email enabled) you will be notified when new posts are made in this thread.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
  1. This thread was already marked as solved.
  2. I really doubt that an XP answer needs further updating.
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

For anyone who is having trouble with regular expressions, I suggest you have a look at this site by Jeff Avallone. It takes a regular expression in the native (cryptic) format and produces a visual display of the same expression. For example,

^[a-z0-9_-]{3,16}$

becomes

Screenshot_(10).png

and the pattern for an email address

^([a-z0-9_.-]+)@([\da-z.-]+).([a-z.]{2,6})$

becomes

Screenshot_(11).png

One caveat - you will see

\d{3,5}

expanded as

Screenshot_(12).png

which may seem incorrect at first glance, however, the 2...4 times refers not to the number of digits but the number of extra "trips" back through the loop so if you have three digits you require two extra trips back through. I recently suggested to the author that he consider labelling the iterators something like 3...5 occurrences which would be both clear and precise.

In any case, this is a valuable tool for debugging complex expressions.

rproffitt commented: 2..4 times or more useful. Molsen OK by you? +12
JamesCherrill commented: Wow - that's really useful. Thanks +15
cereal commented: thank you! +14
ddanbe commented: Great tip! Thanks :) +15
Nutster commented: Good link and explanation, but the Email address pattern needs to escape the period between groups 2 and 3. +7
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Temporary data, by definition, does not need to be saved. If you are referring to saving in one session, then restoring it in another, you would use either My.Settings (which you don't seem to want to use) or some other external store like a database or other file. Typically you would store "like" values in arrays. Holw you store the data depends on the format of the data. Can you give us more details please?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Or, in other words,

If you're going to shoot, shoot. Don't talk.

  • Tuco (TGTBATU)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Why do you insist on writing this in VBA? Why not vb.net which has more capabilities and less overhead?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Works for me here as well in Canada. Windows 10 & Chrome. Also works in Firefox. I might help if you told us what OS and browser, or even what device you are trying to view it on. It's kind of like saying "My car doesn't work. What is wrong with it?"

rproffitt commented: Location matters. Seems some parts of the galaxy block Vimeo. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What have you got so far?

rproffitt commented: Yes. "Show Me What You Got." +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Can you be a little more specific?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Back to my question. If you want to know how long it takes to do the add, doing it through vba is pointless. Just run the executable directly. Also, you are just going to get a value of 0 for testing one addition. Even if you put in a loop to do the operation a million times you won't be able to distinguish between the time it takes to do the addition and the time spent on the rest of the loop processing.

As for writing the text file, try putting the full path and file name of the file you want to write. It's entirely possible the file is being created, just not where you expect it to be.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I didn't claim that anyone was "as bad" as Assad. I just wanted to point out the hypocrisy of the "they shot him ten times but I only shot him once" type of argument. Dead is dead and dying by white phosphor or napalm is probably as bad as by Sarin, Zyklon B, Phosgene or mustard gas. They are all weapons of terror.

The there's MK Ultra. Nobody's hands are clean.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

PS: You should have read the thread that you originally posted in. It gave the same answer that I just posted.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm assuming it is powered by the USB connection. If so, does it work when you use a short cable? If it does than I'm guessing that it just barely gets enough power through the short cable and the power drop over the longer cable means it isn't getting enough power to work.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

if you've forgotten Vietnam as well

Yeah. I would think that any reasonable person would classify untold millions of gallons of Agent Orange as a chemical weapon.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try Shelling devenv instead of test.bat

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can run devenv.exe and build your project from the command line. Type

devenv /?

to get the command line arguments/switches. You'll have to spawn it as an external process. Use the vba Shell call to do that

ret = Shell("command line with args", vbNormalFocus)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Have a look at this and see if it helps.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Two final comments:

Factorial should probably return a long unsigned int rather than a float. And your test

if (n==0)

will cause your function to fail if passed a negative number. You might want to change it to

if (n <= 1)
    return 1;
else
    return n*factorial(n-1);
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You have a couple of problems.

You have to write your own factorial function. However, pow, and cos are in math.h so unless one of your compiler switches is doing something weird they should be defined. I don't use gcc so I can't help there.

Your series expansion is incorrect. Your powers have to be 2, 4, 6... instead of 1, 2, 3...

Your parameters for pow are reversed. Try

double my_cos(double c) {

    int sign = -1;
    double result = 1.0;

    for (int i=2; i<=10; i+=2) {
        result += sign * pow(c,i) / factorial(i);
        sign   = -sign;
    }

    return result;
}

If you need i to be the loop counter you could do

double my_cos(double c) {

    int sign = -1;
    double result = 1.0;

    for (int i=1; i<=10; i++) {
        result += sign * pow(c,2*i) / factorial(2*i);
        sign   = -sign;
    }

    return result;
}
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Google may appreciate it but the rest of us who are repeatedly spammed with junk mail certainly do not.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

According to Dell you are correct - 8 Beeps: Reseat the LCD cable or replace the LCD screen

Dell Beep Codes

If you have an HDMI port (I think that laptop does) you could try cabling to an external monitor with that prior to booting. It might be seen as a duplicate display (showing the same as what would be on your laptop display), whereas a VGA connection might be seen as a second display which might not work until configured through Windows.

rproffitt commented: Tip: Do not take this laptop with you on your next flight. +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

RE: PM. Your input routine should look like

void getUserInput(int *numHospitalRooms, int *numFlowers)
{
    do {
        printf("\nHow many hospital rooms: ");
        scanf("%d", numHospitalRooms);
        if (*numHospitalRooms < 1 || *numHospitalRooms > 5)
        {
            printf("\nInvalid number of rooms, room number must be between 1-5!\n");
        }

    }while((*numHospitalRooms < 1 || *numHospitalRooms > 5));

    do {
        printf("\nEnter number of flowers: ");
        scanf("%d", numFlowers);

        if (*numFlowers < 0)
        {
            printf("\nInvalid number of flowers, negative values are not accepted!\n");
        }

    }while((*numFlowers < 0));
}

Compare the placement of the * and & operators with your original code. You'll also have to make sure that you account for the fact that numHospitalRooms ranges from 1-5 but the array index must be from 0-4. Your calc would then be

float totalCost = (flowerCost + hospitalRoomsPrices_Array[numHospitalRooms] - 1);
catastrophe2 commented: OMG you are a life saver!!! thanks a lot! i suspected & in scanf but i only used it because thats how syntax should be as i learned for c +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

A company in Canada recently lost a class actions suit because of privacy issues. It seems that their product, which can be controlled remotely via smart phone, was collecting temperature, frequency and duration of use and sending it back to the head office. The product was a vibrator (yes, that kind of vibrator). Customers were justifiably upset.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

There was the story about the self driving bike from the Netherlands.

happygeek commented: missed that one, excellent stuff though +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My first program was in BASIC on a mainframe at the University of Saskatchewan in 1971.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I strongly urge you to get into the habit of naming your controls for their purpose. For demo purposes, Button1 and Checkbox1 are fine but in a larger program with many controls it will become impossible to follow your code. A control named btnSubmitForm is a lot clearer than Button17.

rproffitt commented: The old "what does this do?" problem. +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You don't need the line

Dim settings As New My.MySettings

Delete it. Go to

Project -> Properties

then select the Settings tab. Create a variable named ButtonVisible. You should use a name like that rather than checked because it more clearly indicates what state you are trying to preserve. Make ButtonVisible a Boolean. Set the Value field to False.

Your code will look like

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Button1.Visible = My.Settings.ButtonVisible
        CheckBox1.Checked = My.Settings.ButtonVisible

    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

        My.Settings.ButtonVisible = Button1.Visible

    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

        Dim chk As CheckBox = sender
        Button1.Visible = chk.Checked

    End Sub

End Class
rproffitt commented: Classy. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That would depend on what the database engine is and how it is configured. The difference is in the connection string and you can get the correct format here.

Also, depending on the database engine, you will be using ADO, OleDB or SQLclient.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I find that using too high a voltage lets the smoke out of the chips. Once you let the smoke out things stop working. My father-in-law did that with a powered usb hub. Makes a nifty paperweight, though.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Leo: "You seem troubled. What's on your mind"?

Phyllis: "My daughter, Bess, wants to marry a boy whose parents are midgets."

Leo: "What's her problem? Can't she find one?"

rproffitt commented: Skip to 15:15 at https://www.youtube.com/watch?v=asAnq61GZ8g +12
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

We will be happy to help you if you show us what you have done so far and explain what you are having trouble with.