Print Page | Close Window

Drop amount by textbox OR buttons

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=197
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Drop amount by textbox OR buttons
Posted By: Sync
Subject: Drop amount by textbox OR buttons
Date Posted: 11 February 2006 at 3:26pm
Tutorial Difficulty : Easy 1/5

:: ALL CLIENT SIDE ::
Open frmDrop
Add the required controls:
1 option button - optBtns - next to the buttons
1 option button - optTxtbox - next to the textbox
1 text box - txtAmount

[edit]


In the form's code, find
Private Sub ProcessAmmount()
and make it look like this:

Private Sub ProcessAmmount()
Dim InvNum As Long

    InvNum = frmMirage.lstInv.ListIndex + 1
        
    ' Check if more then max and set back to max if so
    If Ammount > GetPlayerInvItemValue(MyIndex, InvNum) Then
        Ammount = GetPlayerInvItemValue(MyIndex, InvNum)
    End If
   
    ' Make sure its not 0
    If Ammount <= 0 Then
        Ammount = 1
    End If
  
    ' Check which option button is clicked
    If optTxtbox.Value = True Then Ammount = txtAmount.Text
   
    If optBtns.Value = True Then
       frmDrop.lblAmmount.Caption = Ammount & "/" & GetPlayerInvItemValue(MyIndex, InvNum)
    End If
End Sub


That's all you need to do! It's that simple!

I hope you liked this tutorial!

[edit2]
Fixes:
Now, also you could go more advanced and make it add to the amount when the button was pressed and optTxtbox was clicked.
I think I left something out here also.

Here's fix 1a of this tutorial:
You have to add this to every button's code on the form. (the +10 -10, etc buttons)
I'm only giving one button's code here though.

Private Sub cmdPlus1_Click()
    If optBtns.Value = True Then
       Ammount = Ammount + 1
       Call ProcessAmmount
    End If
End Sub

and here's fix 1b:
I forgot to add to the textbox's code that when it you type into it,
it has to reprocess the amount.

Private Sub txtAmount_Change()
 If optTxtbox.Value = True Then
    Call ProcessAmmount
 End If
End Sub

That is all known bugs and their fixes with this code.

more fixes:
I discovered more bugs with this tutorial when I was just looking over the code.

Change
If optTxtbox.Value = True Then Ammount = txtAmount.Text

to:
If optTxtbox.Value = True Then
Ammount = txtAmount.Text
lblAmmount.Caption = Ammount
End If


Note: Apply this fix ONLY if you want the amount to reflect in the label lblAmmount's caption.

Thanks!



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info