• Log in or sign up for an account here: https://www.sythe.org/login

[Source] Simple module for games that require buying an item

Blupig

BEEF TOILET
Joined
Nov 23, 2006
Sythe Gold
1,609
Messages
7,145
Age
33
Location
Canada
[Source] Simple module for games that require buying an item
Add this into a module.

Code:
'Made by Blupig. Give credit if you use this in your applications or else I'll hunt you down and gut your dog.
Function Buy(intCost As Integer, intCash As Integer, strCurrency As String, strItemName As String)

    Dim Msg1
        Msg1 = MsgBox("Buy " & strItemName & " for " & strCurrency & intCost & "?", vbYesNo + vbQuestion, "Blupig's Buy Mod")
        
    If Msg1 = vbYes Then
        
        If intCash < intCost Then
            MsgBox "You don't have enough money.", vbInformation, "Blupig's Buy Mod"
        Else: intCash = intCash - intCost
        End If
        
    ElseIf Msg1 = vbNo Then
        Exit Function
    End If

End Function


Sub Main()

    Dim Cost As Integer
    Dim Cash As Integer
    Dim Curr As String
    Dim Item As String
    
        Cost = 19
        Cash = 20
        Curr = "$"
        Item = "Apple"
    
    Call Buy(Cost, Cash, Curr, Item)
    
    MsgBox Curr & Cash & " remains.", vbInformation, "Blupig's Buy Mod"

End Sub
 
[Source] Simple module for games that require buying an item
Seems basic enough but if you want to make it a little more efficient I would say you create a custom type and then make an array to store them in.

Thats how I would do it anyways.
 
[Source] Simple module for games that require buying an item
Seems basic enough but if you want to make it a little more efficient I would say you create a custom type and then make an array to store them in.

Thats how I would do it anyways.

Example? The only way I thought of doing it was to store the data in integers or doubles...
 
[Source] Simple module for games that require buying an item
Something along these lines, I havn't got vb6 installed so I can't try it out. If you google "vb6 type" it will show you how to use them.

Code:
private type item
	name as string
	cost as integer
end type

dim cash as integer
dim items() as item
 
Runescape Gamblingrunescape gambling
Back
Top