I'm learning VB in my school, and i have some homework this weekend. my problem is i've forgotten the proper prefix for a frame, i thought frm, but thats for the form, so whats a frame?
Printable View
I'm learning VB in my school, and i have some homework this weekend. my problem is i've forgotten the proper prefix for a frame, i thought frm, but thats for the form, so whats a frame?
Welcome to Forums! :wave:
There is no such thing as "proer prefix" - most people would use "fra" but it isn't necessary.
You can name your control anyhow you wish - just don't keep the default name and try always changing it to something meaningful:
fraOptions
MyOptionsContainer
mainFrame
MainContainer
... and so one ... however you must be cnsistent with your naming conventions.
my teacher insists that we use them, fra seems to be correct. thanks for the help. i may need a little more so ill just post here rather then making a new thread if it comes to that.
I always use fra, some my forms have 10,000 lines of code, when searching for a frame in the Properties combo they are always grouped together
fraTaxOptions
fraProfitOptions
fraPrintOptions and always use Mixed case
Alright well I need help again. I uploaded what i have (which isnt much) all i've done is porgrammed the done button. But what i have to do is make the frame disabled if the value of either text box is 0. im typing what i wrote but it doesnt work. what i wrote wasbut it doesnt work, I need to make it only recognise text as integer as well but I forget how, I want to learn I dont want it done for me, so if someone could maybe edit mine upload it then I could see how they did it or just tell me what I need to do.Code:fraFunction.Enabled =False if txtNum1.Text = 0
bump
Code:Sub numbersOnly(KeyAscii As Integer, txtBox As TextBox)
On Error GoTo e
If KeyAscii <> 8 And KeyAscii <> 45 And KeyAscii <> 46 And KeyAscii <> 13 Then
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
Beep
End If
End If
If InStr(txtBox, ".") Then 'only allow 1 decimal
If KeyAscii = 46 Then KeyAscii = 0
Exit Sub
End If
If Len(txtBox.Text) > 0 And KeyAscii = 45 Then 'only allow minus sign in leftmost position
KeyAscii = 0
End If
Exit Sub
e:
MsgBox "numbersOnly" & err.number & " " & err.Description
End Sub
woah. that just went clean over my head. im doing basic basic stuff here. that is definatley not the way he shwoed us how to do it. (mind you he didnt show us much) now my brain hurts.
Hi,
I made this Calculator a few years ago back in 2004.
Please download the code and have a look to see if iy helps in anyways.
Thanks
just call it like this:Quote:
Originally Posted by GW2live
Private Sub text1_KeyPress(KeyAscii As Integer)
numbersOnly KeyAscii, text1
Exit Sub
In case you haven't realised, the form of the If statement is the other way round to the way you tried
should beCode:fraFunction.Enabled =False if txtNum1.Text = 0
In general, the If statement syntax is:Code:If txtNum1.Text = 0 Then fraFunction.Enabled = False
The Else clause is optional but the End If is mandatory unless the whole statement is on one line. SoCode:
If <some condition> Then
'
' Code goes here if <some condition> evaluates to True
'
Else
'
' Code goes here if <some condition> evaluates to False
'
End If
is valid, as isCode:If x <> 0 Then Y = 20
butCode:If X <> 0 Then
Y = 20
End If
is not valid.Code:If X <> 0 Then
Y = 20
A couple of general tips in case your Teacher doesn't insist on them:
(a) Always put Option Explicit in the Declarations Section of your Form. It forces you to define all the variables you use and will save you countless hours of debugging.
(b) Indent your code (eg as I have done with the If / Then / Else / End If above) when you use If / Select Case / Do / For / and any other statements that are executed in "Blocks". IT makes the code easier to read and understand and also it's fairly obvious is you've missed things like End If off a block of code
eg
In the above it's not too obvious that there's an End If missing, whereasCode:If X = 20 Then
If y=30 Then
z=4
Else
z=7
End If
q=34
It's fairly obvious that there's an End If missing just by looking at the indentation.Code:If X = 20 Then
If Y = 30 Then
z=4
Else
z=7
End If
q = 34