473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Add from one label to another label!!!!!!!!!

52
hi,
i'm tryin to create this math questions form for my sister. the form has 2 labels where random numbers show, a text box where the answer is entered, a next button the next numbers and an exit button.

This is my next button and my random number generator.
Private Sub Command2_Click()
'
If Val(lbl1) * Val(lbl2) = txta.Text Then 'txta.text is the textbox were the answer is entered
txta.Text = ""
Random
lblQno.Caption = Val(lblQno.Caption) + 1 ' label showa how many questions answered

ElseIf Not Val(lbl1) * Val(lbl2) = txta.Text Then
txta.Text = ""
Random
lblQno.Caption = Val(lblQno.Caption) + 1
End If
End Sub

Public Sub Random()
Randomize
lbl1 = Int(Rnd * 13)
lbl2 = Int(Rnd * 13)
End Sub

what i want is that when the question is answered the numbers on lbl1 and lbl2 should then be in caption in 2 other labels on another form. this should happen even if the answer is wrong. i'm thinkin that it may be some array or something but i'm not sure. Could anyone please help me solve this problem & if there is anything i need to further explain then please tell me. THANK YOU
Mar 3 '08 #1
2 1176
jamesd0142
469 256MB
What version of vb is this?

if you want to generate a random number better to use something like...

Expand|Select|Wrap|Line Numbers
  1. Dim b As Integer = System.DateTime.Now.Millisecond
  2.  
Mar 3 '08 #2
kadghar
1,295 Expert 1GB
hmmm

Using Randomize will change the seed, using the miliseconds of the time, so it's even a better and easier method, but there's no need to use it each time you generate numbers, if you use it only once, at the beginig, its good enough.

to write something in another form, remember the controls of a form are also its children. so you can do:

Expand|Select|Wrap|Line Numbers
  1. Form2.label1.caption = me.label1.caption
or use the controls list:

Expand|Select|Wrap|Line Numbers
  1. form2.controls("label1").caption = me.label1.caption
This should work for some versions, but if it doesnt, it'll help if you tell us the version of VB you're using.

by the way, there's no need of using ElseIf Not(..) in this very case, something like this should do
Expand|Select|Wrap|Line Numbers
  1. if a*b = txt1.text then
  2.     'whatever it does when its right
  3. else
  4.    'whatever it does when its wrong.
  5. end if
HTH
Mar 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Grim Reaper | last post by:
I asked this question, earlier, and received an answer that I am not sure about how to do. Basically, I am printing mailing labels with a "Sorting/Grouping" section that groups the label types...
2
by: Marcelo | last post by:
Hi guys, I'm using the following code to send values from one page to another, but seems to me, that the event Page_Load in the receiving page never fires. Why? This is the code: Thanks ...
0
by: Sebastian Hiller | last post by:
Hello, i'm new to .Net (i'm using VB as language and i'm working in the code-behind mode) and i can't solve the following problem: I have a WebForm and want to Add a UserControl...
1
by: nospamjac | last post by:
Hi, Is there a way to update the text of an asp:label on a webform without refreshing the entire page? What is called by button clicks and other events that refresh a webform control? See the...
4
by: Ron | last post by:
Hello, I created an array of label controls like this: Dim lbl() As Label = {Me.lbl1, Me.lbl2, Me.lbl3} and was able to iterate through the array. But then I saw another way to declare the...
1
by: simon | last post by:
Hello, i'm looking to create an aspx page that is basically a FAQ page i'm not sure if this can be done, but would love some help with suggestions of how to do it another way if this is not...
8
by: Arpan | last post by:
Consider the following code snippet (my main intention is to display the current time in a Label control as & when this ASPX page is accessed/refreshed): <script runat="server"> Class Clock...
1
by: Praveen | last post by:
I want to read individual disk label for Hard disk (C: drive, D: drive disk label) and CD-ROM disk label Please provide some pointer to the code or document. Thanks in advance.
1
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.