VB.NET Modules

Chikanman

Well-known member
Joined
Dec 14, 2012
Posts
75
Location
UK
First off, WOW I haven't been on Sysnative in a while.

Anyhoo, on to my problem. I've been getting a load more ambitious in VB over the Christmas holidays, and I decided I'd try and make a little text-based game. For organisation, I've been using module files for storing certain groups of functions - for example, ones which draw on the XML 'scenario' I wrote. The issue I've been getting is that, when I try and use these in the form... nothing happens. For example, here is my current (incomplete) code for Form1.Load:

Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load        'MakeNewCharacter()
        RichTextBox1.AppendText(Scenario.GetIntroString() & ControlChars.NewLine & ControlChars.NewLine)
        If Scenario.HasMob(Inc.ToString) Then
            If Not MobCombat(Myself, Scenario.GetMob(Inc.ToString)) Then
                Me.Close()
            End If
        ElseIf Scenario.HasBoss(Inc.ToString) Then
            If Not Bosscombat(Myself, Scenario.GetBoss(Inc.ToString)) Then
                Me.Close()
            End If
        End If

End Sub

Obviously Form1 is my form, and RichTextBox1 is a text box on that form. The issue I'm getting is that, for whatever reason, when my program tries to access a function in another module, nothing happens - no errors or anything, it just doesn't do anything. For example, if I put RichTextBox1.AppendText("Blargh") before anything, it will put "Blargh" in the text box. However, put it after that first line, and it won't. If I change it to give an MsgBox(), I won't get the box if it contains a call to that module. Even if I change the Scenario.GetIntroString() function to just return a simple string without actually doing anything - e.g.

Code:
Public Function GetIntroString() As String        
      Return "Test"
      'Return ScenarioRoot.Element("scenario").Element("intro").Value.ToString
End Function

I still get nothing. Can anyone tell me something I'm doing wrong? I've got all the different files under the same VS solution, I've tried adding the files to the main form file as imports, I've tried copying the whole module into the main file but nothing seems to work.

I thought my first proper attempt at Linq and light OOP would be the source of my problems, how wrong was I! But hey, at least that all works :D
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top