

InterviewSolution
1. |
Solve : Basic Visual Basic 6.0 Help? |
Answer» Hi to you all Computer Expert 2. By putting money= 200 in a subroutine you're creating a scope problem; code it inline in the module. caliorg is undefined...you may not have posted enough code.i already have my money save as single money = 200 and i want to do a further calculation with it. Module: Public money as Single Public nUnit as interger Private Sub Form1_activate() money = 200 caliorg = 25.50 and nUnit is a number the user specify End Sub Private Sub Buy_Click() If Option1.Value = True Then money = money - (caliorg * nUnit) backpack.Caption = caliorg & " " & nUnit & "Unit" End If End Sub This it what i want to do but it doesnot work Quote 3. I can't make out from your code what you're trying to do but I think days only has scope within the subroutine and reverts back to zero after the subroutine ends. Try making days a global field.I want to click on a button that will change its number by 1 every time i click on it. So what i mean is that every time i click the button it will add up the number of 1 everytime. Quote 4. Not sure on this; you can always use the unload method on the form followed by the load method. Why would you need to do this? Forms are updated as the underlying data changes.True i dont really need this Quote 5. Use the rand() function.How can i limit the number. Let say i want the number to by random between 10 - 30 and it go to be single so sometime the number will be 15.67 or 20.64 ect. 2 & 3: It's time to start debugging your code. Best way is to set a well placed breakpoint, run the job interactively and as soon as you hit the breakpoint, step into the code and see how the program runs and what values the fields take on. There seems to be some doubt that the _Activate event ever runs. The VB package has a very full and rich help function which should answer most of your questions. 5: Code: [Select]Public Function Rand(ByVal Low As Long, _ ByVal High As Long) As Long Rand = Int((High - Low + 1) * Rnd) + Low End Function I mistyped RND as RAND in my earlier post. Sorry for the confusion. It might also be wise to execute a RANDOMIZE instruction in the FORM_LOAD event to seed the random number generator. 8-)You are a great help thankyouQuote 2 & 3: It's time to start debugging your code. Best way is to set a well placed breakpoint, run the job interactively and as soon as you hit the breakpoint, step into the code and see how the program runs and what values the fields take on. There seems to be some doubt that the _Activate event ever runs. The VB package has a very full and rich help function which should answer most of your questions. I don't understand why you need to use this function?If you don't mind to explain it to me.Thanks. As I know in vb if you want to convert string to int you only to write this code. For example : Dim total As Integer total = CInt(txtTotal.text) same if you want to convert label. caption. Eg : Dim total As Integer total = CInt(lblTotal.Caption) or if you want to convert it to Double just write: Dim total as Double total = CDbl(lbltotal.Caption) Which function are you talking about? The rand function was used as a teaching aid to show the original poster how to create random numbers. A function was used since by definition a function returns a result. If you're referring to the Int function, the integer portion of the result from the Rnd function is needed, so it was necessary to truncate the decimal portion. CInt would have rounded the result to the nearest even number. Fix could also have been used in this case. When dealing with VB functions, always read the fine print. 8-) Note: using the .text and .caption properties in numeric conversions will crash and burn your program should they resolve to non-numeric strings. |
|