Results 1 to 3 of 3

Thread: Damn visual basic

  1. #1
    Variable Bitrate BiohazrD's Avatar
    Join Date
    Sep 2004
    Location
    Katy TX
    Posts
    431

    Damn visual basic

    Check this out...
    Code:
    Imports System.IO
    Public Class Form1
        Inherits System.Windows.Forms.Form
        Private fu As Form1
        Private WithEvents fs As Form2
        Public Shared nick As String
        Public Shared server As String
        Private path As String
        Private sr As StreamReader
        Private sw As StreamWriter
        Private socket As New System.Net.Sockets.TcpClient
        Private connected As Boolean = False
        Private ss As System.Net.Sockets.NetworkStream
        Private encrypt As New encryption
        Private thread As System.Threading.Thread
        Private rtba(1) As RichTextBox
        Private lv As Integer
    
    #Region " Windows Form Designer generated code "
    #End Region
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            rtba(0) = New RichTextBox
            TabPage1.Text = "Main"
            TabControl1.Enabled = False
            MenuItem6.Enabled = False
            MenuItem7.Enabled = False
            path = "pr.dat"
            fs = New Form2
            StatusBar1.Dock = DockStyle.Bottom
            StatusBar1.Text = "Disconnected"
            Try
                If Not File.Exists(path) Then : goSettings()
                Else
                    sr = New StreamReader(path)
                    nick = sr.ReadLine()
                    server = sr.ReadLine()
                    sr.Close()
                End If
            Catch ev As Exception
                MsgBox("You cannot run this program from a network share")
                End
            End Try
        End Sub
    
        Private Sub processinput(ByVal x As String)
            If x.StartsWith("do>") Then
                'process the function
            ElseIf x.StartsWith("pm>") Then
                'send to right index
            Else : rtba(0).AppendText(x)
            End If
        End Sub
    
        Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tabcontrol1.SelectedIndexChanged
            mainchatbox = rtba(TabControl1.SelectedIndex())
            If Not TabControl1.SelectedIndex = 0 Then
                MenuItem6.Enabled = True
                MenuItem7.Enabled = True
            Else
                MenuItem6.Enabled = False
                MenuItem7.Enabled = False
            End If
        End Sub
    
        Private Sub ListBox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
            TabControl1.Enabled = True
            If Not ListBox1.SelectedIndex = -1 Then TabControl1.Controls.Add(New TabPage(ListBox1.SelectedIndex.ToString()))
            ReDim rtba(rtba.Length() + 1)
            rtba(TabControl1.SelectedIndex()) = New RichTextBox
        End Sub
    
        Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click
            TabControl1.Controls.RemoveAt(TabControl1.SelectedIndex)
            For lv = TabControl1.SelectedIndex To TabControl1.TabCount - 1
                rtba(lv) = rtba(lv + 1)
            Next
            ReDim rtba(rtba.Length() - 1)
        End Sub
    
        Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
            save()
            End
        End Sub
    
        Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
            goSettings()
        End Sub
    
        Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
            If Not connected Then
                Try
                    socket.Connect(server, 6667)
                    StatusBar1.Text = "Connected"
                    Button1.Enabled = True
                    MenuItem3.Text = "Disconnect"
                    ss = socket.GetStream
                    thread = New Threading.Thread(AddressOf checkstream)
                Catch ev As Exception
                    MsgBox("Could not connect to server.", MsgBoxStyle.Exclamation, "Connection Error")
                End Try
            Else
                socket.Close()
                StatusBar1.Text = "Disconnected"
                Button1.Enabled = False
                MenuItem3.Text = "Connect"
                ss.Close()
            End If
        End Sub
    
        Shared Sub changeNickWhileConnected(ByVal x As String)
            'send new nick to server
            nick = x
        End Sub
    
        Public Sub f2c() Handles fs.ev
            Me.Enabled = True
            save()
        End Sub
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            sw.WriteLine(textEnter.Text)
            textEnter.Text = ""
        End Sub
    
        Private Sub checkstream()
            If Not sr.Peek = -1 Then : processinput(sr.ReadLine)
            End If
        End Sub
    
    
        Private Sub save()
            sw = New StreamWriter(path)
            sw.WriteLine(nick)
            sw.WriteLine(server)
            sw.Flush()
            sw.Close()
        End Sub
    
        Public Sub goSettings()
            fs.TextBox1.Text = nick
            fs.TextBox2.Text = server
            If connected Then
                fs.TextBox2.Enabled = False
            End If
            Me.Enabled = False
            fs.Visible = True
        End Sub
    End Class
    For some reason, the tab index changed method runs before form_load, and its ******* everything up.
    Quick! To the Popemobile!

  2. #2
    FLAC IntellaWorks's Avatar
    Join Date
    Jun 2004
    Location
    NH
    Posts
    1,173

    .

    Step through with the debugger go through line for line...

    Take a quick break b4 you do it though sometimes walking away for a bit helps...

    Good luck
    Progress [I will seriously never be done!]
    Via EPIA MII
    512MB RAM
    OEM GPS (embedded)
    nLite WinXP pro on
    1GB Extreme III CF card
    Carnetix 1260 startup/ DC-DC regulator
    Software: Still, re-Writing my existing front end in .Net

  3. #3
    cheap custom title JC-S60's Avatar
    Join Date
    Mar 2004
    Location
    Ghent - Belgium
    Posts
    1,863
    or the ugly fix: doevents

Similar Threads

  1. Visual Basic Question????
    By chuckctv in forum Software & Software Development
    Replies: 9
    Last Post: 12-28-2004, 12:25 PM
  2. FREE Visual Basic .NET SE & ASP.NET Development Book
    By hevnsnt in forum Software & Software Development
    Replies: 3
    Last Post: 10-06-2004, 11:22 AM
  3. Radio visual basic BT878
    By NEO in forum Software & Software Development
    Replies: 0
    Last Post: 10-31-2003, 05:28 PM
  4. Adding Gamepad input in Visual Basic
    By UBCSJonw in forum Software & Software Development
    Replies: 1
    Last Post: 09-10-2003, 09:00 PM
  5. i need a visual basic OCX for an generic infrared receiver
    By babas151 in forum Software & Software Development
    Replies: 9
    Last Post: 04-20-2002, 03:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •