Dang, i thought i had this first try, in like 10 lines of code. heres my project.
http://s5.yousendit.com/d.aspx?id=2Q...H2VTHQB5RWJEQ2
The problem is on this line of code, z = x & y & Val(Calc.Caption)
It seems vb wont evaluate it. Any ideas?
Printable View
Dang, i thought i had this first try, in like 10 lines of code. heres my project.
http://s5.yousendit.com/d.aspx?id=2Q...H2VTHQB5RWJEQ2
The problem is on this line of code, z = x & y & Val(Calc.Caption)
It seems vb wont evaluate it. Any ideas?
You can't use & for anything except strings.
VB Code:
z = x + y + Val(Calc.Caption)
dg, that doesnt make sense with my code at all though.
say x = 5, y = /, Val(Calc.Caption) = 3
youd be writing this.
5 + / 3
that wont work : (
what else could i use
im still learning and so can't help you at the moment.....
i just wanted to knw some parts in your code;.....and design
first of all i wud like to ask is whether u have created a control array for ur digits?
and does the (Index) refer to the index of the control array?
index refers to the caption of whatever i click on, yes its an array
Maybe you could use this:
VB Code:
Option Explicit ' Add a reference to Microsoft Script Control 1.0 Private Sub Form_Load() Dim x As New ScriptControl x.Language = "vbScript" MsgBox Format(x.Eval("(49*48*47*46*45*44)/(1*2*3*4*5*6)"), "standard") End Sub
uhhh...are you sure you posted in the right topic? *** is that? lol
Would this help you more?
VB Code:
Option Explicit ' Add a reference to Microsoft Script Control 1.0 Private Sub Form_Load() Dim x As New ScriptControl Dim z%, a%, q$ z = 55 a = 24 q = "*" x.Language = "vbScript" MsgBox Format(x.Eval(z & q & a), "standard") End Sub
It prints out 1,320.00, which is 55 x 24 :wave:
heck yes it would. ill check it out
user defined type not defined, also wahts the "standard")
Not entirely true: ampersand is a "shortcut" for LONG data type soQuote:
Originally Posted by dglienna
z& = x& + y&
is perfectly valid syntax ...
VAL() isn't the best way of getting numeric value(s) from string ...Quote:
Originally Posted by dglienna
That's just for the format command. You can leave it off if you want.
Its the same as Format(x,"#.##") You can use Standard, and a few others.
Where's the error? Try This.
Sorry. I was referring to mathematical evaulations. Also used in Hexidecimal Notation.Quote:
Originally Posted by RhinoBull
Option Explicit
Dim x As Integer, y As String, z As Integer, zz As Integer
Private Sub Cmd_Click(Index As Integer)
x = Calc.Caption
y = Cmd(Index).Caption
End Sub
Private Sub Command1_Click(Index As Integer)
Calc.Caption = Command1(Index).Caption
If Len(x) > 0 Then
z = x & y & Val(Calc.Caption)
Calc.Caption = z
End If
End Sub
please insert as you would :D
I posted the project that you could try. Didn't it work? #12
Add the reference to your project and you can use EVAL to compute the value.
i didnt see it , ill look now
Heres my whole code.
VB Code:
Option Explicit Dim x As Integer, y As String, z As Integer, zz As Integer Private Sub Cmd_Click(Index As Integer) x = Calc.Caption y = Cmd(Index).Caption End Sub Private Sub Command1_Click(Index As Integer) Calc.Caption = Command1(Index).Caption If Len(x) > 0 Then ' z = x & y & Val(Calc.Caption) Calc.Caption = (b.Eval(x & y & Calc.Caption)) End If End Sub Private Sub Form_Load() Dim b As New ScriptControl b.Language = "vbScript" End Sub
It highlights dim b as new scriptcontrol an says user type not defined or something...it works on your form though, ***? wahts wrong?
Did you add the reference?
' Add a reference to Microsoft Script Control 1.0
Click Project -> References, and check the box next to it.
You can also put the DIM statement in the General Declarations section at the top of your form. Calc.caption needs val(), too
no i didnt add it *slaps himself*
val(Calc.Caption) needs to be changed, too. :wave:
*invalid use of new keyword*
Dim b As New ScriptControl
Post your code.
VB Code:
Option Explicit Dim x As Integer, y As String, z As Integer, zz As Integer Dim b As New ScriptControl Private Sub Cmd_Click(Index As Integer) x = Calc.Caption y = Cmd(Index).Caption End Sub Private Sub Command1_Click(Index As Integer) Calc.Caption = Command1(Index).Caption If Len(x) > 0 Then ' z = x & y & Val(Calc.Caption) Calc.Caption = (b.Eval(x & y & Calc.Caption)) End If End Sub Private Sub Form_Load() b.Language = "vbScript" End Sub
Click Project -> References, and scroll down to Microsoft Script Controls 6.0 and tick the box. That should do it. I replaces your textboxes (because you didn't post the project with your forms :( )
Here is the code that keeps multiplying the value of the button.
VB Code:
Option Explicit Dim x As Integer, y As String, z As Integer, zz As Integer Dim b As New ScriptControl Private Sub Command1_Click() x = 22: y = "*" Command1.Caption = b.Eval(x & y & Val(Command1.Caption)) End Sub Private Sub Form_Load() Command1.Caption = 8 b.Language = "vbScript" End Sub
Zip your project, and upload it as an attachment. I'll fix it for you.
You have a Private Message :wave:
done
I don't know what kind of project you started up, but you also saved the form as module1.bas, which could have helped to mess things up. I tried a lot of different things, before finally deleting everything except the renamed module (to a form) and added it to a new project. It works now, but you can only have single digit numbers. I'll let you work that one out.
This was a major pita. Never seen it before.
lmao really? Well i had an old calculator thing, and i guess i saved it over the old module..I didnt think it worked that way :D
by golly thats funny :D
wait, it works, which is good :thumb:
but i dont see a microsoft scripting control anywhere on your form, or in the properties anywhere!!
wt..?
I thought i had to add that, and i dont get any errors without it here...
its not in components, which you had checked, and had a control in your form.
you need the reference, which isn't a control per se, you just include the references that you want to use in your program. There are two choices from the Project menu Refernces and Components (cntrl-T).
That's the difference.
oh k, cool, thanks dg :thumb: