Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Visual Basic 2008 Help

Featured Replies

I am working on a "Monster Buddy" Program. All it does is gets information on a monster I search for. Here is my current source.

 

 

 

 

 

 

 

 

 

[hide=My Code]


Imports System.IO

Imports System.IO.File



Public Class Form1





   Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click

       Dim oFile As System.IO.File

       Dim oRead As StreamReader



       'Get Text File

       oRead = oFile.OpenText("c:\\monsters\" & Me.txtSearch.Text.ToLower & ".txt")

       Dim monstername As String

       Dim combatlevel As String

       Dim weakness As String

       Dim maxHit As String



       'Monster Name (Line 1)

       monstername = oRead.ReadLine

       Me.lblMonsterName.Text = monstername



       'Combat level (line 2)

       combatlevel = oRead.ReadLine

       Me.lblCombatlvl.Text = combatlevel



       'Weakness (line 3)

       weakness = oRead.ReadLine

       Me.lblWeakness.Text = weakness



       'Max Hit (line 4)

       maxHit = oRead.ReadLine

       Me.lblMaxHit.Text = maxHit



   End Sub

End Class



 

Text in "man.text"

 

 

 

 

Bob

 

Combat 12

 

Poop

 

60

 

 

It gets each item and puts it in the correct spot.[/hide]

 

 

 

That is just a basic set up. I don't plan to use those categories. I have to use separate text files for each monster. 100+ text files is a lot tbh.

 

 

 

Is there a way to put everything in 1 text file then have it locate the information in the file then start from it?

 

 

 

(well I know there is, but I don't know how =p)

 

 

 

~~bballer

wii_wheaton.png

[software Engineer] -

[Ability Bar Suggestion] - [Gaming Enthusiast]

I would guess you would put descriptive names in the text file, have matching names in a dropdown list, and have a loop statement that finds the file, and reads off the information, pasting it in a listbox. It would have to iterate through the loop a certain number of lines (for i=1, i <= 4, i++), which would fit your example)...Trying to think of the code for it, but I can't seem to remember..

 

 

 

You could try looking at http://www.vbforums.com/showthread.php?p=2316263. I took at look at the code and got confused, but then again I was looking at it in Notepad++ and not through VB.

 

 

 

http://www.ostrosoft.com/vb/projects/textfind.asp

 

 

 

Maybe I'll try something like this in Java, but for WoW. Seems like a good project that would encompass quite a few different elements.

[hide=Funny Quotes]

So you sucker punched a kid in the back of the head? Good job.
What scares me is that you're like 10 years old.
-.- im not that freaking young
You were a couple years ago.
It's not racist if its true.
Hmm... I wonder how one goes about throwing someone out a window in a mystic fashion :-k

 

The mental image for that is freaking awesome.

[/hide]

- I dont need to "get a life." I'm a gamer - I have LOTS of lives!

I am not much a VB man myself but i am sure Clare could help you with this one.

The quickest way to do this is to make a sort of text file array, each line contains all the data for each entry separated by something like |, here's an example:

 

 

 

Bob|Combat 12|Poop|60

 

Fred|Combat 88|Whoop|70

 

 

 

You could read it all in a loop until EOF, loading the details into an Array, I don't have time to write you any code right now but if I get the chance, I will knock something up later on.

Time to beat Clare to the mark, lol.

 

[hide=Code]

    Dim FileName As String = "C:\monsters\master.txt"

   Dim MonsterArray(3, 1000) As String

   Dim PossibleMatches(3, 100) As String



   Private Sub cbxMatches_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxMatches.SelectedIndexChanged

       lblName.Text = PossibleMatches(0, cbxMatches.SelectedIndex)

       lblCombat.Text = PossibleMatches(1, cbxMatches.SelectedIndex)

       lblWeakness.Text = PossibleMatches(2, cbxMatches.SelectedIndex)

       lblMaxHit.Text = PossibleMatches(3, cbxMatches.SelectedIndex)

   End Sub



   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

       'Get Text File

       Dim sBuffer As String

       Dim ArrayBuffer(3) As String

       Dim Count As Integer = -1

       Dim Count2 As Integer = 0

       FileOpen(1, FileName, OpenMode.Input)

       While Not EOF(1)

           Count += 1

           sBuffer = LineInput(1)

           ArrayBuffer = Split(sBuffer, "|")

           For i = 0 To 3

               MonsterArray(i, Count) = ArrayBuffer(i)

           Next

       End While

       FileClose(1)

       For i = 0 To Count

           If MonsterArray(0, i).ToLower = txtSearch.Text.ToLower Then

               For t = 0 To 3

                   PossibleMatches(t, Count2) = MonsterArray(t, i)

               Next

               cbxMatches.Items.Add(PossibleMatches(0, Count2))

               Count2 += 1

           End If

       Next

       If Count2 <> 0 Then

           cbxMatches.SelectedIndex = 0

           lblName.Text = PossibleMatches(0, 0)

           lblCombat.Text = PossibleMatches(1, 0)

           lblWeakness.Text = PossibleMatches(2, 0)

           lblMaxHit.Text = PossibleMatches(3, 0)

       End If

   End Sub

[/hide]

 

 

 

That fills an array with possible matches as well as uses the format of file Clare reccommended.

 

 

 

Of course I bet Clare will come up with something better/easier.

[hide=Drops]

  • Dragon Axe x11
    Berserker Ring x9
    Warrior Ring x8
    Seercull
    Dragon Med
    Dragon Boots x4 - all less then 30 kc
    Godsword Shard (bandos)
    Granite Maul x 3

Solo only - doesn't include barrows[/hide][hide=Stats]

joe_da_studd.png[/hide]

No that's pretty much what I was going to do :geek: .

 

 

 

I was also going to show the method of reading and writing to files using ini format, this may be a bit more flexible. The functions I have for these (Which also enables to you manipulate the registry as well as ini files) work perfectly in VB6 but I haven't tested them in VB2008 yet, I need to do that when I get home tonight. Unfortunately My boyfriend and I are going shopping directly after work and then I promised to cook a meal afterwards, so it might be tomorrow morning ;)

 

 

 

Joe, thanks for rising to the occasion :)

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.