Working on an RPG.
For the items, I have a text file with the format
ID# <> NameofItem <> TypeofItem <> ValueofItem
To test the call, I made a sample form with a text box and a command button.
Private Sub cmdNewItem_Click()
Item = txtItem.Text
If Item = "" Then Item = 0
Sub CreateItem(ByVal ItemNo As Integer)
fileItems = App.Path + "\Data\Items.dcl"
If ItemNo = 0 Then ItemNo = 100
If ItemNo < 100 Or ItemNo > 300 Then
MsgBox "Invalid Item ID Detected(" & ItemNo & ")"
'Note About File Set Up
'fileItems format for items is as follows:
'ID% <> Name <> Type <> Value
'Icon = ID%
Open fileItems For Input As #1
Do Until EOF(1)
Line Input #1, Temp$
ID% = Split(Temp$, "<>")(0)
If ItemNo = ID% Then
Items(ItemNo).ID = Split(Temp$, "<>")(0)
Items(ItemNo).Name = Split(Temp$, "<>")(1)
Items(ItemNo).Type = Split(Temp$, "<>")(2)
Items(ItemNo).Value = Split(Temp$, "<>")(3)
Items(ItemNo).Icon = ID%
If Items(ItemNo).Type = "Armor" Then
MsgBox "You found a suit of " & Items(ItemNo).Name & "!"
MsgBox "You found a " & Items(ItemNo).Name & "!"
Universe.NoOfItems = Universe.NoOfItems + 1
Every time I try to run this little tidbit...if I set the ID equal to 100 by any means, it's give me the appropriate "You found a Dagger!" MsgBox. It also recognizes the invalid IDs (below 100, above 300). Any number above one hundred and below three hundred, the accepted range, however, gives me a "Subscript out of range" error. Debug points at the line "Items(ItemNo).ID = Split(Temp$, "<>")(0)" in CreateItem. This is the second time I've had split errors in a program; the last tiem it happened I just had to sit and toy with it until i foudn some thick, bulky code to cover it up. Is there anyone who knwos how to fix this, or who can at least pass me a fair reason why the subcript is out of range? I'd be greatly appreciative for any help.