I am a drafter using autocad and I know a littttttle bit of VB6. We just happen to have it installed on our computers and I wanted to create an application that can do this:

1. Takes the # input from text1 and text2 and waits for the user to hit "Ok" (command click)

2. Upon clicking, the information from Text2 gets multiplied by 0.75, and the total sum is then compared to Text1 with a less than or equals to equation.

3. the comparison then Decides if the sendkeys will say "G152B" or "CB152B" to Notepad

Without words i guess?...

text2.text * "0.75" = SUM (this is the part im not really entire sure how to do, variable maybe?)

text1 and text2 filled out by user, user hits ok

command1_click()
If Sum <= text1.text then
sendkeys "g152b" else
Sendkeys "cb152b"

The first thing you need to do is to make sure that the content of both the textboxes are indeed numeric.
The function for that is called IsNumeric and returns a boolean value.

Second. In order to perform any calculations you need to convert the numeric strings in the textboxes. …

## All 2 Replies

The first thing you need to do is to make sure that the content of both the textboxes are indeed numeric.
The function for that is called IsNumeric and returns a boolean value.

Second. In order to perform any calculations you need to convert the numeric strings in the textboxes. And because you are multiplying with a decimal value, you need to convert them into Double.

So.The calculation would look something like this.

``````Dim product As Double

If IsNumeric(textbox2.Text) = True Then
product = CDbl(Val(textbox2.Text)) * 0.75

If IsNumeric(textbox1.Text) = True Then
If product <= CDbl(Val(textbox1.Text)) Then
SendKeys "g152b"
Else
SendKeys "cb152b"
End If
End If``````

If you need to limit the number of decimals this might produce you can use the Round() function.
`product = Round(product, <number of decimals, 0 is default>)`

Hi, I know you asked for something in vb6, but anyone who runs the code needs to install the VBA Enabler, so I wrote something in LiSP that could do the trick as well. If you make it an application, then anyone can run it, just send them the VLX.
The first bit is the lsp code. In the first line the word "ProgramName" can be changed to whatever you want to call your program.
In the 4th line (load_dialog) that would be the path to your dcl file. I use that when testing, but before you pick File > Make Application, you would comment that line and uncomment the line below it.

``````(prompt "Loading ProgramName  Enter 'compare' to start.")
(defun C:compare ()

(setq dcl_id (load_dialog "N:\\__New LiSP programs\\daniweb\\compare.dcl")) ;comment this line when making an application
;(setq dcl_id (load_dialog "test.dcl")) ;uncomment when you make an application
(if (not (new_dialog "compare" dcl_id) ) (exit)) ;should match the first line in dcl
(mode_tile "input1" 0)
(mode_tile "input2" 0)
(action_tile "fileName" "(setq fileName \$value)")
(action_tile "input1" "(setq input1 \$value)")
(action_tile "input2" "(setq input2 \$value)")
(action_tile "accept" "(exit_Main)")
(action_tile "cancel" "(done_dialog 0)")
(setq next (start_dialog))
(if (= next 1)
(progn
(setq fnamePath (strcat (getvar "dwgprefix") fileName "." "txt"))
(setq output (open fnamePath "w"))
(if (<= (distof input2 2) (distof input1 2))
(setq rtnVal "g152b")
(setq rtnVal "cb152b")
)
(princ rtnVal output)
(close output)
(setq a1 (strcat fnamePath "\nHas been created."))
(princ)
)
) ;ends if next = 1
) ;ends program

(defun exit_main()
(done_dialog 1)
) ;ends function``````

This is the DCL file that goes with the LiSP

``````compare : dialog {
label = "Number Compare";
:edit_box {
key = "fileName";
label = "Filename (prefix)";
edit_width = 10;
}
:edit_box {
key = "input1";
label = "Enter first value:";
edit_width = 10;
}
:edit_box {
key = "input2";
label = "Enter second value";
edit_width = 10;
}
ok_cancel;
}``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.