![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0
![]() |
import namespace
I created a streamreader:
Dim sOut As System.IO.StreamReader But the code I got off a web-page was: Dim sOut as streamreader I know this is a basic question but I haven’t quite got my head around OOP. I’m guessing that the second lot of code would have had the namespace system.IO imported thus visual studios knows where to look for streamreader. My question is how would I use the import or what ever is required to get the second lot of code to work in a “public class form1" button.click procedure without having pre-pend the system.IO Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myProcess As Process = New Process()
Dim s As String
myProcess.StartInfo.FileName = "cmd.exe"
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.RedirectStandardInput = True
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.RedirectStandardError = True
myProcess.Start()
Dim sIn As System.IO.StreamWriter = myProcess.StandardInput
sIn.AutoFlush = True
Dim sOut As System.IO.StreamReader = myProcess.StandardOutput
Dim sErr As System.IO.StreamReader = myProcess.StandardError
sIn.Write("ping.exe" & System.Environment.NewLine)
sIn.Write("exit" & System.Environment.NewLine)
s = sOut.ReadToEnd()
If Not myProcess.HasExited Then
myProcess.Kill()
End If
sIn.Close()
sOut.Close()
sErr.Close()
myProcess.Close()
MessageBox.Show(s)
End Sub
End ClassI hope this makes sense. If it doesn’t then I will try to clarify to the best of my ability's within my limited programming vocabulary. hush |
|
|
|
|
|
#2 |
|
Unverified User
Join Date: Aug 2006
Posts: 88
Rep Power: 0
![]() |
You say at the top of the class or module
Imports System.IO //you can imports any namespaces here with the Imports keyword Class Foo //could be module Foo //Random programming goes here End Class It will then be avaliable in any classes or modules that are in that file. I think thats about right. I have not done much VB.net ![]() |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0
![]() |
Thanks RS
i was trying all sorts as i like to figure this stuff out myself, i even tried that without the 's' on the end of imports. i won't be forgeting that in a while. is it the same for c#? |
|
|
|
|
|
#4 |
|
Unverified User
Join Date: Aug 2006
Posts: 88
Rep Power: 0
![]() |
C# uses the keyword using, but the concept is the same.
e.g.
using System.IO;
class Foo{
//blah blah
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Java CS Project | Watts | Existing Project Development | 12 | Jun 20th, 2006 3:39 PM |
| method doesn't recognize variable | Krista | Java | 1 | Dec 5th, 2005 5:40 PM |
| converting from javax.swing.JTextField to java.lang.String | Krista | Java | 5 | Dec 5th, 2005 4:08 PM |
| C++ namespace question | kevin_cpp | C++ | 1 | May 17th, 2005 3:28 PM |
| what is the import command? | arod199113 | Python | 13 | Feb 11th, 2005 1:18 AM |