• 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

$5 USD Donor
Joined
Nov 23, 2006
Sythe Gold
1,609
Messages
7,145
Age
33
Location
Canada
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
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
 
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.
 
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
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...
 
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