|
You could use a microcontroller and send data via the rs232 port!
I don’t know your electronics abilities, but a simple PIC16F84 or PIC16F628 would be suitable, you can even use BASIC to program the PIC. Just create a basic selection program and control it via VB.NET.
Trust me there are thousands of examples on the net!
|
|
|
|
|
Hello,
I am coding a text editor program. I creat my main form with a menu. While the user hit a menu item, a different form would come out and ask for input. After that, I would like the change reflected in the main form, say, TextBox1 in the main form.
Can somebody give suggestions?
Best,
Hui
|
|
|
|
|
Different way of accomplishing it.
Common one, and easiest, is:
sub form1clickwhattever....
form2.show
me.textbox1.text = form2.controlwithdata.text
end sub
|
|
|
|
|
Thanks for the reply. I tried to use the code in my program. However, it does not work. I would like the me.textbox1.text get changed after the user click on an OK button in the 2nd form. The code above replaces the textbox1.text with a blank string, since the user has not filled out the info yet. I guess that I need to refer to the caller (main form) in the called form (child form), but I don't know how to refer to the main form in the child form. In Visual Basic 6, I think I can just call its name but not in Visual Basic .Net. Any suggestions?
|
|
|
|
|
Well my code has an error or better it was missing the form2.showdialog (so that the next line is executed only after the form2 has been hidden/closed with the button).
So if you replace .show with .showdialog then it works.
Anyway if you want a more precise answer you should provide more precise informations. Which versione of FW are you using 1.x or 2? VS2003 or VS2005.
In VS2003 you can refer to the calling form only if it's public declared.
Module x
public fmain as new frmMain
end module
then in the form2 button click event handler:
fmain.textbox1.text = ....
In VS2005 in most cases you can state immediatly the form without instancing it. This means you can have a direct access to frmMain (considering the previous example) unless you're running an instance created by you (than you fallback in the former case).
Another way of doing it is by raising an event.
In form2 you'll have:
...
raisevevent OKClicked()
and in form1
private sub ClickOnForm2() handles frm2.OKClicked
me.textbox1.text = frm2.textbox1.text
end sub
or using parameters ...
public class frm2eventargs
inherits eventargs
public t as string
end class
on form2 before you raise the event...
dim e as new frm2eventargs
e.t = (text to pass)
raiseevent OKClicked(me,e)
and then on the mainform
private sub frm2OKClick(sender as object,e as frm2eventargs) handles frm2.OKClicked
me.textbox1.text = t
end sub
So as you can see lot of options depending on the approach you want and what you're using.
|
|
|
|
|
At a other site on the web (http://www.codeguru.com/columns/VB/article.php/c6529[^]) I found a sample for TypeConverters. I played a little with this sample: I added a new class 'TestControl' (Inherited from UserControl) with one userdefinded-Property 'TestProperty As Circle'. If I add my TestControl to a Form, the IDE generates the following Code:
Me.TestControl1.TestProperty = CType(resources.GetObject("TestControl1.TestProperty"), tester.Circle)
And now there comes my problem: I want that the TestProperty becomes a ReadOnly-Property and die generated Code has to look like this:
Me.TestControl1.TestProperty.X = 4<br />
Me.TestControl1.TestProperty.Y = 5<br />
Me.TestControl1.TestProperty.Radius = 3
Is this posible or want I too much?
|
|
|
|
|
|
The second time you helped me much. Thanks
|
|
|
|
|
Your welcome (for both times of course )!
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Is there simple way to find out how many records there are in a database table? Access database table that is.
|
|
|
|
|
The only way with Access I knowing is the following SQL-Statement:
SELECT COUNT(*) AS TableCount FROM [Table]
|
|
|
|
|
Hi
I am trying to draw a rectangle over an existing image by using the following code (pb is the PictureBox and has an image)
<br />
Dim oGraphics As Graphics = Graphics.FromImage(pb.Image)<br />
With oGraphics<br />
.DrawRectangle(New Pen(Color.Red, 2), New Rectangle(5, 5, 300, 300))<br />
End With<br />
pb.Refresh()<br />
The problem comes when I want to draw another rectangle (at a different location) and I can't remove/clear the existing rectangle before drawing the new one.
Is there any way I can remove the existing drawn rectangle?
I don't want to use the pb.CreateGraphics() b/c the drawing is not consistent when this method is used.
I am using the FromImage() method b/c later I want to resize (zoom) or rotate the image with drawn rectangle and It won't require any further coding for rotating and resizing the rectangle.
I tried reload the Image again, but large images take to much time to load, so I want to avoid the Image reloading.
Please help!
|
|
|
|
|
Maybe you can load the image, and the clone it, and the put the clone in the pb? That way, when you want to remove the stuff you were drawing on the image of the pb, you can dispose that image and put a new clone of the original in the pb. I think on large images cloning takes much time too, but less that reloading it.
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
I haven't worked with graphics for a while, so I don't know how hard this would be, but could you lay down the image first, and then overlay a transparent picturebox on the first image? Then, instead of drawing the rectange directly on the image, you can draw it over the image, on the second picturebox.
Roy.
|
|
|
|
|
Thank You Roy,
I am not sure and don't remember it correctly (I read it somewhere) that there is something like a Xor Pen.
Is there anything like this that can help me?
Another CP user in the C# forum suggested me that I should remember the Pixel values of the image (for rectangular area) before drawing the rectangle. How do I remember those values and how to reload those values?
|
|
|
|
|
Hello, how can i make a chat messanger using the ips! i want to send a message from a computer to another computer in another house not in my house! I want the program to send a message to another pc using ips! Thanks alot!!
Adrian De Battista
|
|
|
|
|
Try looking at the TcpClient, TcpListener and NetworkStream classes in the System.Net namespace.
|
|
|
|
|
As the subject suggest how can i monitor CPU.
|
|
|
|
|
Maybe this[^] is what you're looking for?
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Hi All ,
how can i receive the ip address from a remote client?
im using this code to listen to a client:
dim PORT as integer = 10000
listener = New Sockets.TcpListener(System.Net.IPAddress.Any, PORT)
listener.Start()
Dim client As TcpClient = listener.AcceptTcpClient()
now i need the client ip address ?....
|
|
|
|
|
hey all,
Does anyone know, how to determine the port of a printer? I need this to know because my application allows a user to select a printer but all print jobs are send directly to the port (i.E. "copy print.txt LPT1").
I do not find any information abount this
I'm using VB.NET 1.1
thx, bernd
|
|
|
|
|
The GetPrinter API can be used from VB.Net to get this info.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Thx very much !!
after knowing what i am looking for i found this:
<DllImport("winspool.drv", CharSet:=CharSet.Auto, SetLastError:=True)> _
Private Shared Function OpenPrinter( _
ByVal pPrinterName As String, ByRef hPrinter As IntPtr, _
ByVal pDefault As IntPtr) As Boolean
End Function
<DllImport("winspool.drv", CharSet:=CharSet.Auto, _
SetLastError:=True)> _
Private Shared Function ClosePrinter( _
ByVal hPrinter As IntPtr) As Boolean
End Function
<DllImport("winspool.drv", CharSet:=CharSet.Auto, _
SetLastError:=True)> _
Private Shared Function GetPrinter( _
ByVal hPrinter As IntPtr, ByVal dwLevel As Integer, _
ByVal pPrinter As IntPtr, ByVal cbBuf As Integer, _
ByRef pcbNeeded As Integer) As Boolean
End Function
Private Shared Function GetPrinterInfo(ByVal printerName As String) As PRINTER_INFO_2
Dim hPrinter As IntPtr
If Not OpenPrinter(printerName, hPrinter, IntPtr.Zero) Then
Throw New Win32Exception(Marshal.GetLastWin32Error())
End If
Dim pPrinterInfo As IntPtr = IntPtr.Zero
Try
Dim needed As Integer
GetPrinter(hPrinter, 2, IntPtr.Zero, 0, needed)
If needed <= 0 Then
Throw New Exception("Na Zeavas...")
End If
pPrinterInfo = Marshal.AllocHGlobal(needed)
Dim temp As Integer
If Not GetPrinter(hPrinter, 2, pPrinterInfo, needed, temp) Then
Throw New Win32Exception(Marshal.GetLastWin32Error())
End If
Dim printerInfo As PRINTER_INFO_2 = _
CType(Marshal.PtrToStructure( _
pPrinterInfo, GetType(PRINTER_INFO_2)), PRINTER_INFO_2)
Return printerInfo
Finally
ClosePrinter(hPrinter)
Marshal.FreeHGlobal(pPrinterInfo)
End Try
End Function
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Public Structure PRINTER_INFO_2
Public pServerName As String
Public pPrinterName As String
Public pShareName As String
Public pPortName As String
Public pDriverName As String
Public pComment As String
Public pLocation As String
Public pDevMode As IntPtr
Public pSepFile As String
Public pPrintProcessor As String
Public pDatatype As String
Public pParameters As String
Public pSecurityDescriptor As IntPtr
Public Attributes As System.UInt32
Public Priority As System.UInt32
Public DefaultPriority As System.UInt32
Public StartTime As System.UInt32
Public UntilTime As System.UInt32
Public Status As System.UInt32
Public cJobs As System.UInt32
Public AveragePPM As System.UInt32
End Structure
|
|
|
|
|
Hi,
Cud you suggest me a way to bind one textbox with two tables?
i'l tell u the actual situation.
I am having n text box on a tab page.Some of the textboxes get the data from a previously filled table.i need to fill data in other textboxes and want to save the data of all the text boxes in another table.
Im having a primary data in one of the textboxs and many records for that primary data has to be saved n times.
Thanx
|
|
|
|
|
Hi,
I am new in VB.net. I have a problem while debugging a windows application, which will read a bmp image and save it after processing. I used the following code
//Opening an image
private sub button1_click (Byval sender as object,Byval e as system.eventergs)
dim odlg as new openfiledialog()
odlg.filter = "Bitmap(*.bmp)|*.bmp"
if (odlg.showdialog=dialogresult.ok) then
picturebox1.image = image.fromfile(odlg.filename)
picturebox1.invalidate()
end if
end sub
//Saving an Image
private sub button2_click (Byval sender as object,Byval e as system.eventergs)
dim sdlg as new savefiledialog()
sdlg.filter = "Bitmap(*.bmp)|*.bmp"
if (sdlg.showdialog=dialogresult.ok) then
picturebox1.image.save(sdlg.filename)
picturebox1.invalidate()
end if
end sub
While I open an image "b.bmp" and after processing it want to overwrite the file with the same filename (b.bmp) an error occurs, saying:
"An unhandled exception of type
System.Runtime.InteropServices.ExternalException occurred in System.Drawing.dll
Additional information: A generic error occurred in GDI+."
What should I do now, how can i overcome this problem?
Please help me. Thanks in advance.
Anindya Chatterjee
|
|
|
|