BigSeckC 2 Newbie Poster

not a command as far as i know, there use to be a sleep command in qbasic (i think)... but writing a pause sub is doable to say the least... assuming one was written for use with this program, how its set up could be part of the problem i guess...

funny, i've never used form.visible = true / false to show or hide forms... always just used .show or .hide... didn't even know it worked until now... well there's my new thing for the day ;)

[edit]ok... so i probably shouldn't be posting at 6:30 am with no sleep... sorry, didn't notice the second page :$ [/edit]

LOL - hear ya... the way the code was written it appeared as though 'Pause' was being called as a Procedure - i haven't run into anything denoting that command :)

so i was just kinda assuming and hoping that i'm learning something XD

squidd commented: an E for Effort +2
BigSeckC 2 Newbie Poster

awwwwwwwwww NUTS... was hoping something may have fixed this... I'm with you right now - possibly the different IF statements in your procedures. Took a small break from coding this weekend to let some things sink in for me before I move on - but I'm definitely watching this thread and *crosses fingers for a fix...

sorry man... i tried :)

BigSeckC 2 Newbie Poster

Hi I'm completely new to using VB in excel, but could someone help me fix my program. I'm supposed to find the roots of the equation denoted as func using the newton raphson method. Currently I am not getting the correct roots and the range of values which can be input are very limited. Could someone help on how to fix this? Thanks!

Option Explicit
Function newton(guess)

Dim func As Double, deriv As Double, i As Double, x2 As Double, x As Double, dif As Double

x = guess

For i = 0 To 1000
    func = x ^ 2 * Sin(x) + x ^ 3 * Exp(x) - x * Cos(x) - 7
    deriv = (x ^ 2 - 1) * Cos(x) + 3 * x * Sin(x) + (x ^ 3 + 3 * x ^ 2) * Exp(x)
    x2 = (x - func) / deriv
    dif = x2 - x
    x = x2
    If Abs(dif) < 0.001 Then i = 1000
Next i

newton = x
    
End Function

I'm new too - so if I'm wrong, i apologize now...

First off, are you using VBA? (Visual Basic for Applications) - I've read that there are some inherent differences between it and 'regular' VB...

That being said, and here's where my math fails me, when calculating Sin and Cos - is it written as Sin(#) / Cos(#)?

Standard math says that x(y) = multiplication - so, are the numbers being multiplied by accident?

*scratches …

BigSeckC 2 Newbie Poster

what is the use of the for loop ?

That's old school Basic. For i = 0 to 1000 is telling the proggie to start counting at 0 and stop at 1000. The func... statement has the proggie calculating each number it sees. Next i is telling the proggie move forward to the next number in the sequence....

(i.e., Start counting at 0, perform calculations, move on to next number (1,2,3,4,5...1000) )

Since 'for' is 0 to 1000 - it automatically stops at 1000.

...at least that's what it used to mean on the 'Trash 80's' (Radio Shack TRS-80 Microcomputer - w/ or w/o monitor)

...yea... i know... I just dated mahsef...

:cool:

BigSeckC 2 Newbie Poster

NP.... as I said before, I'm learning too so I'm having to use 'logic' to try and decode the code :D

I'm hoping to find an answer too because I have a project in mind that could run into the same type of situation. Solve it now, less headache later :twisted:

BigSeckC 2 Newbie Poster

what is that PAUSE in your code ?

I'm assuming that the program is being told to wait 1.5 seconds before continuing. Is 'pause' not a valid command?

It makes sense 'logically'...but if it's not a command - it's not a command. :P

BigSeckC 2 Newbie Poster

Just looking at the code again...

What procedure is tied to '1:'?

End If
1:
End Sub

...maybe there is something there...

BigSeckC 2 Newbie Poster

I know - it's truly weird - the reasoning behind the Do..While is:

"technically" if the code is "looping" without being told to, a Do...While 'should', in effect, negate the situation. (e.g., Do this - While that - Then Quit)

The only other things I can think of would be:

1. Run the program on another box - "maybe"there is 'something' on the code box that is causing the anomaly. (e.g., bad memory address, bad spot on HDD, etc.)

2. Re-write the code using a New Form and Test with each New Line - maybe even on a different box - 1 of 2 reasons...

A. The existing file could be corrupted. <-- not entirely impossible.

B. In testing each line, you would be narrowing down where 'the loop' is coming into play.

...right now, it's honestly the only things I can think of.

*crosses fingers for a corrupted file...

Not to insult your intelligence, but by box - I mean computer. Just in case someone else was wondering...

...why do I have this sneaky feeling I'm gonna run into this too?...:sweat:

BigSeckC 2 Newbie Poster

Ok... time to state the obvious... it's Looping the code.

Would a 'Do...While' help in this situation? I'm asking this as a general question to anyone...

Seems like that 'could/would' work - but I'm not proficient enough to say 'do this'.

Have you tried googling a 'pw reset snippet'? I had to do that once and it did help me understand what I was doing wrong :)

BigSeckC 2 Newbie Poster

Got it!!! Figured out the Code I needed... at least for now...

'coding Confirm to calculate

Private Sub cmdconfirm_Click()

If opta.Value = True Then
    intgsal = (txthrs.Text * 10)
       txtgsal.Text = intgsal
    intnet = (intgsal - txtded.Text)
        txtnet.Text = intnet
End If
End Sub
BigSeckC 2 Newbie Poster

A copy of the actual code would be nice... I'm learning myself and this is definitely issue that I foresee in my future. :cool:

BigSeckC 2 Newbie Poster

Is this an issue when they refer to a 'memory leak'?

I am also assuming that you mean 'log off the program' and not logging off the OS. Again, assuming, if you reboot your system - the program works normally?

BigSeckC 2 Newbie Poster

Hey all,

I apologize now for being a Noob. I'm using a Tutorial to learn VB6 (for starters) and everything was going great until just now... The assignment is to create a Weekly Payroll. I have managed to figure out how to make the standard calc ( Hrs worked * Rate ) and display properly, however, that's when my legs get knocked out from under me :D

I'm not entirely sure how to subtract the deductions. I tried searching but couldn't find a similar situation. Below is my working code, albeit probably OC'd... over-coded.

*scratches head... how do I subtract? I 'thought' it would be:

If opta.Value = True Then _
intgsal = (txthrs.Text * 10) _
And intnet = (txthrs.Text * 10 - txtded.Text) <-- txtded.Text being my Deductions

txtgsal.Text = intgsal
txtnet.Text = intnet

...I was sooooo wrong... more errors than a little bit! :D


My 'working' code is below - any help would be appreciated! Also, if there are shortcuts (i.e., functions) that I could use in the future - I would like to know that as well!

Thanks again!

'setting up Integers for
'calculations

Option Explicit
    Dim intgsal As Integer   'Gross Salary
    Dim intnet As Integer    'Net Salary
    Dim inthrs As Integer    'Hours Worked
    Dim intded As Integer    'Deductions

'setting text box values to
'"blank" and "0"

Private Sub Form_Load()
    txtname.Text = " "
    txthrs.Text = "0.00"
    txtded.Text = "0.00" …