locked
Module form RRS feed

  • Question

  • I have two forms one a normal forum  "form1"    and a module form  "module Ippa".

     

    On my main form I have a button to click and then i must run the module form, but I cannot get it to run, how do you run a module form, I can get it to run my about form, but not the module Ippa form.

    Wednesday, June 18, 2008 8:22 AM

Answers

  • When you use for each you are looping through a collection of items . Your code only puts the last item into the text box . For example if I use this code .

     

    Code Snippet

    Imports System.Net.NetworkInformation

     

    Public Class Form1

     

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

     

    Dim returnValue As NetworkInterface()

    returnValue = NetworkInterface.GetAllNetworkInterfaces()

    For Each RV As NetworkInterface In returnValue

    TextBox1.AppendText(RV.Description & vbCrLf)

    Next

     

    End Sub

     

    End Class

     

     

    I get this in textbox1

     

    Code Snippet

     

    NVIDIA nForce Networking Controller - Packet Scheduler Miniport
    MS TCP Loopback interface

     

     

    MS TCP Loopback interface is a loop back to your computer the same as using the ip address 127.0.0.1 . If you don't use append text with a textbox then each time through the loop the text is replaced by the new text instead of the new text being added to the textbox
    Friday, June 20, 2008 9:50 AM

All replies

  • Again, my ignorance is showing because I don't know what a "module form" is.  Neither Google nor MSDN turned up anything useful on this phrase.

     

    Please post the code you are using to create a "module form".

    Wednesday, June 18, 2008 12:32 PM
  • If Ippa is just a module you need to call the function in it that you want.


    Wednesday, June 18, 2008 1:38 PM
  • As you can see on screen one.  Appi.vb is where the module is.

     

     

     

    On screen two is some of the code.   I want to know how can I call this code to used on my main form,  I can not get it to run.

     

    Thursday, June 19, 2008 7:46 AM
  • Call the sub

     

    Code Snippet

    Public Class Form1

     

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

     

    main()

     

    End Sub

     

    End Class

     

     

    Code Snippet

     

    Module Module1

     

    Sub main()

    MessageBox.Show("Hello World", "Module messagebox")

    End Sub

     

    End Module

     

     

    Thursday, June 19, 2008 8:56 AM
  • I have done this, but when I run the program and click on the button nothing is happening.

     

    Form1

    Code Snippet

    Private Sub Toets1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Toets1.Click

     

    Main()

     

    End Sub

     

     

    Appi.vb

    Code Snippet

    Imports System

    Imports System.Collections.Generic

    Imports System.Text

    Imports System.Net

    Imports System.Net.NetworkInformation

    Module Ippa

    Sub Main()

    ShowNetworkInformation()

    Console.ReadLine()

    End Sub

    Public Sub ShowNetworkInformation()

    Dim ipProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()

    Console.WriteLine("Host name: {0}", ipProperties.HostName)

    Console.WriteLine("Domain name: {0}", ipProperties.DomainName)

    For Each networkCard As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces()

    Console.WriteLine("Interface: {0}", networkCard.Id)

    Console.WriteLine("" & Chr(9) & " Name: {0}", networkCard.Name)

    Console.WriteLine("" & Chr(9) & " Description: {0}", networkCard.Description)

    Console.WriteLine("" & Chr(9) & " Status: {0}", networkCard.OperationalStatus)

    Console.WriteLine("" & Chr(9) & " MAC Address: {0}", networkCard.GetPhysicalAddress().ToString())

    Console.WriteLine("" & Chr(9) & " Gateway Address:")

    For Each gatewayAddr As GatewayIPAddressInformation In networkCard.GetIPProperties().GatewayAddresses

    Console.WriteLine("" & Chr(9) & "" & Chr(9) & " Gateway entry: {0}", gatewayAddr.Address.ToString())

    Next

    Console.WriteLine("" & Chr(9) & " DNS Settings:")

    For Each address As IPAddress In networkCard.GetIPProperties().DnsAddresses

    Console.WriteLine("" & Chr(9) & "" & Chr(9) & " DNS entry: {0}", address.ToString())

    Next

    Next

    End Sub

    End Module

     

     

    Thursday, June 19, 2008 9:29 AM
  • It looks like you have taken this code from a console application but are trying to use it in a Windows Forms application where Console.WriteLine has little use.

     

    If you look at the output window (Ctrl-Alt-O) you should see the output of the sub main.

     

    If you want to use it in a Forms app then modify the code to write to a multi-line textbox or a label.

    Thursday, June 19, 2008 10:14 AM
  • Thank you Dave299

     

    I am trying to change it I got diffrent text box for each one now (don't know yet how to put it in one multi line texbox)

     

    It shows the first two Host and domain name, but when I try the  4 one it give me this error

     

    Card name   "MS TCP Loopback interface"

     

    It has something to do with thsi code

     

    For Each networkCard As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces()

    'TextBox3.Text = networkCard.Id

    TextBox3.Text = networkCard.Name

     

    Thursday, June 19, 2008 11:36 AM
  • Replace console.writeline with textbox3.appendtext( "Your text"  & vbcrlf )

     

    vbcrlf is a line feed so the next text added goes to next line .

     

    Thursday, June 19, 2008 12:12 PM
  • I don't get closer to what I watn to do, What am I doing wrong.

     

    Here is the code and a screenshot of what I am getting

    Code Snippet

    Public Class IPAdd

    Public defaultGateway As String

    Private Sub IPAdd_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim ipProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()

    TextBox1.Text = ipProperties.HostName

    TextBox2.Text = ipProperties.DomainName

    For Each networkCard As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces()

    TextBox3.Text = networkCard.Id

    TextBox4.Text = networkCard.Name

    TextBox5.Text = networkCard.Description

    TextBox6.Text = networkCard.OperationalStatus

    TextBox7.Text = networkCard.GetPhysicalAddress().ToString()

    For Each gatewayAddr As GatewayIPAddressInformation In networkCard.GetIPProperties().GatewayAddresses

    TextBox8.Text = defaultGateway

    Next

    For Each address As IPAddress In networkCard.GetIPProperties().DnsAddresses

    TextBox10.Text = address.ToString()

    Next

    Next

    End Sub

     

     

     

     

     

    Friday, June 20, 2008 8:02 AM
  • When you use for each you are looping through a collection of items . Your code only puts the last item into the text box . For example if I use this code .

     

    Code Snippet

    Imports System.Net.NetworkInformation

     

    Public Class Form1

     

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

     

    Dim returnValue As NetworkInterface()

    returnValue = NetworkInterface.GetAllNetworkInterfaces()

    For Each RV As NetworkInterface In returnValue

    TextBox1.AppendText(RV.Description & vbCrLf)

    Next

     

    End Sub

     

    End Class

     

     

    I get this in textbox1

     

    Code Snippet

     

    NVIDIA nForce Networking Controller - Packet Scheduler Miniport
    MS TCP Loopback interface

     

     

    MS TCP Loopback interface is a loop back to your computer the same as using the ip address 127.0.0.1 . If you don't use append text with a textbox then each time through the loop the text is replaced by the new text instead of the new text being added to the textbox
    Friday, June 20, 2008 9:50 AM
  •  bdbodger

     

    Thank you, I understrand it now.

    Friday, June 20, 2008 11:20 AM