|
i want to connect a lamp to my pc via com1 or any ports and write a simple code using vb.net to control on/off???
|
|
|
|
|
|
I assume your talking about an LED and not a 110/220V light bulb!
First, the serial port is a bad choice to connect an LED to. It's cumbersome to control since most signals only last a fraction of a second on the serial port and there are only a few lines that will actually hold a signal up or down. The better choice for this would be the Parallel port. You can find many exmaples of this on the web.
A good example, complete with LED's and switch inputs, can be found at http://www.logix4u.net[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
<br />
Friend Sub renderPicture()<br />
Dim previewFile, tempPreviewFile As String<br />
Dim numberOfSelectedItem As Integer<br />
Dim bitmapSource As Bitmap<br />
Dim graphicDestination As Graphics<br />
Dim selectedFileName As String<br />
Dim scale As Single<br />
<br />
If Not picPreview.Image Is Nothing Then<br />
picPreview.Image.Dispose()<br />
End If<br />
<br />
If Not bitmapDestination Is Nothing Then<br />
bitmapDestination.Dispose()<br />
End If<br />
<br />
numberOfSelectedItem = lstFiles.SelectedItems.Count<br />
<br />
If numberOfSelectedItem > 0 Then<br />
Dim dummy = lstFiles.SelectedItems.Item(numberOfSelectedItem - 1)<br />
previewFile = UCase(previewCachePath).Replace("SCANNED FILES", "SCANNE~1") & Mid(dummy, 1, Len(dummy) - 4) & "001.png"<br />
tempPreviewFile = UCase(previewCachePath).Replace("SCANNED FILES", "SCANNE~1") & Mid(dummy, 1, Len(dummy) - 4) & "[t].png"<br />
If System.IO.File.Exists(previewFile) Then<br />
If Not System.IO.File.Exists(tempPreviewFile) Then<br />
System.IO.File.Copy(previewFile, tempPreviewFile)<br />
End If<br />
End If<br />
<br />
Try<br />
bitmapSource = New Bitmap(Bitmap.FromFile(tempPreviewFile))<br />
Catch ex As Exception<br />
Module1.setErrMsg(ex.Message)<br />
Exit Sub<br />
End Try<br />
Select Case cmbZoom.Text<br />
Case "150%"<br />
scale = CSng(1.5)<br />
Case "125%"<br />
scale = CSng(1.25)<br />
Case "100%"<br />
scale = CSng(1.0)<br />
Case "75%"<br />
scale = CSng(0.75)<br />
Case "50%"<br />
scale = CSng(0.5)<br />
Case "25%"<br />
scale = CSng(0.25)<br />
Case "Fit Width"<br />
scale = CSng((panPreview.Width - 17) / bitmapSource.Width)<br />
Case Else<br />
Module1.setErrMsg("Error on Wrong Zoom Scale")<br />
Exit Sub<br />
End Select<br />
<br />
'If scale = CSng(9.9) Then<br />
' scale = CSng((picPreview.Width) / bitmapSource.Width)<br />
'End If<br />
bitmapDestination = New Bitmap(CInt(bitmapSource.Width * scale), CInt(bitmapSource.Height * scale))<br />
graphicDestination = Graphics.FromImage(bitmapDestination)<br />
graphicDestination.DrawImage(bitmapSource, 0, 0, bitmapDestination.Width + 1, bitmapDestination.Height + 1)<br />
picPreview.Width = bitmapDestination.Width<br />
picPreview.Height = bitmapDestination.Height<br />
picPreview.Image = bitmapDestination<br />
bitmapSource.Dispose()<br />
graphicDestination.Dispose()<br />
Else<br />
picPreview.Image = Nothing<br />
End If<br />
End Sub<br />
When I go thorugh this function to repeat the same picture Time by time,
The memory accumulate 3MB each time!!
Anyone can help me to see what the problem is??
How can I improve it?
|
|
|
|
|
|
And stop looking at TaskManager to see how much memory your using. You're actually seeing how much memory the CLR's virtual machine is holding onto, NOT much much memory your app is actually using. Use the Performance Monitor and the .NET CLR Memory counters if you want to see how much memory your app is using.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know what you mean actually,
but the number of memory shown on the task manager will shown to the end user.
Can I make the number shown on Task Manager is also low?
|
|
|
|
|
cylix2000 wrote: but the number of memory shown on the task manager will shown to the end user.
So what?
cylix2000 wrote: Can I make the number shown on Task Manager is also low?
Not without calling the GarbageCollector directly. This is never done, unless you have a really good reason for doing it and know the consequences are! Doing this "just because I don't want my customer to think my app is a memory hog" is not good enough. The GC is self-tuning. You WILL cause your app major performance problems by constantly forcing the GC to run early.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: cylix2000 wrote:
but the number of memory shown on the task manager will shown to the end user.
So what?
IMHO
It did happen alot, customers asking about our application perfomance, especially when we were selling the application. They will start saying something like "my old program or another program ( using another language ) didnt behave like this. are you sure your program is ok?". And then they start to "feel" that when running our application, they computer run slower. And also customers, most of them, didnt have IT background. Explaining them about what behind it, is sometime useless. What they see is what they believe.
The result of this are unsatisfied customer and a change of loosing business opportunities.
That's why a lot of people been asking and they will keep asking about it in the future. In CP forum itself, almost everyday there's a question about it.
CMIIW
WiL
|
|
|
|
|
shiroamachi wrote: They will start saying something like "my old program or another program ( using another language ) didnt behave like this. are you sure your program is ok?". And then they start to "feel" that when running our application, they computer run slower.
This is a consequence of the environment and tools you are using - in this case Microsoft Windows, .NET Framework and VB. There are ways around it but they ALL include either rewriting the program in a different language or using different libraries or both. I know one guy who does all his own programming and never uses the framework nor the VC++ class libraries. As a consequence he has very compact and efficient code BUT it takes him MUCH MUCH longer to write, debug etc. That's the tradeoff by using rapid application development tools. (BTW, Microsoft is not the only supplier of resource-hungry dev tools.)
shiroamachi wrote: And also customers, most of them, didnt have IT background. Explaining them about what behind it, is sometime useless. What they see is what they believe.
I know what you mean. Non-IT trained (savvy) people never understand, but most of them never understand how an internal combustion engine works either since they are not trained mechanics but they still drive them to work everyday.
shiroamachi wrote: The result of this are unsatisfied customer and a change of loosing business opportunities.
That's why a lot of people been asking and they will keep asking about it in the future.
This is the job of the pre-sales guys and sales reps. They should properly manage the customer's expectations and be ready for the inevitable "why is it so" questions.
shiroamachi wrote: In CP forum itself, almost everyday there's a question about it.
Yes, sadly not many developers understand it either.
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
In VB.NET, when some huge data processing is going on, the form turns blank (Nothing is visible to the user, sort of hangs). However, the processing goes on correctly and the form becomes normal after the processing is completed. Can someone tell me how this can be prevented. Thnx...
With Best Regards,
Mayur
|
|
|
|
|
mayhem_rules wrote: when some huge data processing is going on
Use a thread for processing this data.
You are doing processing in the main GUI thread. Hence it hangs.
Branch out the processing onto a different thread. You'll see the difference.
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Thnx for your reply. Since I am relatively new to .NET, I really do not have much idea about threading. Could you explain it to me or provide some samples. Also, I am using a progress bar to try and keep the screen active. But no luck. Thnx a lot.
With Best Regards,
Mayur
-- modified at 4:32 Thursday 19th January, 2006
|
|
|
|
|
|
Thnx a lot, I will try it out an let u know.
With Best Regards,
Mayur
|
|
|
|
|
How to make a image button ?
How to make some rounded corner text field?
Thanks
|
|
|
|
|
cylix2000 wrote: How to make a image button ?
What is that?
Put an image onto a button. Button has the image property. Select an image.
cylix2000 wrote: How to make some rounded corner text field?
You've got to paint it like that.
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I am using VS.NET 2003 / Windows XP. I want to export the data displayed in the datagrid into EXCEL. I have checked that 'Microsoft Excel 11.0 and 5.0 Object Library' is present in Add Reference. Can someone provide code for the same.
With Best Regards,
Mayur
|
|
|
|
|
You can simply use the dataset and write it as xml
<br />
Dim fs As New System.IO.FileStream("c:\myfile.xls", _<br />
System.IO.FileMode.Create)<br />
<br />
'Create an XmlTextWriter for the FileStream.<br />
Dim xtw As New System.Xml.XmlTextWriter(fs, _<br />
System.Text.Encoding.Unicode)<br />
xtw.WriteProcessingInstruction("xml", "version='1.0'")<br />
datasetname.WriteXml(xtw)<br />
xtw.Close()<br />
the above code will write a file c:\myfile.xls
Regards
Mubashir
|
|
|
|
|
Hi Mubashir, thnx for your reply. I used the code provided above. It creates a myfile.xls file in c drive. Since the data size is huge, the file size is 24 mb. However, when I try to open the file, the screen just displays importing data or opening. However, nothing is displayed in excel eventhough I have waited for a long time. Please help me out.
With Best Regards,
Mayur
|
|
|
|
|
|
Hi Abhinav,
I have already gone through the link provided in your reply. However, there are some issues that I have with the steps provided.
I am using VS.NET 2003 / Windows XP / Office 2003
In the following steps,
Dim excelApp As New Excel.Application
Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add
Dim excelWorksheet As Excel.Worksheet = _
CType(excelBook.Worksheets(1), Excel.Worksheet)
I have added a reference to Excel 10.0 Object. However, it displays error message for the above code.
For the line, Dim excelApp As New Excel.Application, the options provided is _Application.
Also for, Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add, there is no workbooks.add property available.
Can you help me out with this. It is very important for me. Thnx a lot for your concern.
With Best Regards,
Mayur
|
|
|
|
|
i did it like this:
Dim excelApp As Object<br />
Dim excelBook As Object<br />
' to Workbook to Worksheet.<br />
excelApp = CreateObject("Excel.Application")<br />
excelBook = excelApp.Workbooks.Add<br />
Dim excelWorksheet = excelBook.worksheets(1)<br />
excelApp.Visible = True
try it
abhinav
|
|
|
|
|
I have a listbox which can multiple select.
How can I get the newest selectItem ?
I means I have already select 2 item, how can I get the last item i selected?
Suppose the user may random select.
|
|
|
|
|
'Declare a form level variable as
Inherits System.Windows.Forms.Form
Private lstLastItem As Integer
'Move the index of selected item of list box into the lstLastItem
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
lstLastItem = ListBox1.SelectedIndex
End Sub
|
|
|
|