|
You can't scan the serial port. You can send some information to the device, and see if it answers.
---
b { font-weight: normal; }
|
|
|
|
|
Hello,
New to VB.net, doing an exercise from a book, I am getting a warning message @ below function. Warning message is
"function 'padquotes' does not return a value on all code paths. A null reference exception could occur @ runtime when the result is used"
getting similar warning messages on other fucntions also. How do i fix this problem.
Function padquotes(ByVal strin As String) As String
Try
padquotes = strin.Replace("'", "''")
Catch ex As Exception
'error handler done here
unhandledexceptionhandler()
End Try
End Function
|
|
|
|
|
Hi,
When you define a function that means that function should return a value. This return type is specified in the signature itself. In this case it is string.
Function padquotes(ByVal strin As String) As String<br />
Try<br />
padquotes = strin.Replace("'", "''")<br />
<br />
Catch ex As Exception<br />
'error handler done here<br />
unhandledexceptionhandler()<br />
<br />
End Try<br />
End Function
But what if an exception occurs? You have handeled it, but in that case what should be the output of the function ?
You should ideally return nothing or an empty string in this case.
change ur catch block to -
Catch ex As Exception
'error handler done here
unhandledexceptionhandler()
return nothing ' or return ""
End Try
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hey im having problems using the linked list.
Linked list and LinkedListNode.
I can't seem to access the next and previous pointers in the LinkedListMode.
I have the following
Private _Vehicle As LinkedListNode(Of Vehicle)
Private _vehicles As New LinkedList(Of Vehicle)
So basically i got a vehicle class.
And i want to have a collection of vehicles but stored in a linkedlist.
im using the LinkedListNode because i need to be able to access the next and previous vehicles in the list.
When i go through the linked list i do
dim v as vehicle
for each v in _vehicles
v.vehicletype = "car" //just an example
Next
but in this loop i can access the properties of vehicle but not of the node. i.e. next, previous!
Can somebody kindly show me how i can do this
or use the lists properly. Thankyou
|
|
|
|
|
|
Hello
In the below code I found on the internet I would like to use in a vb app and have the result in a multi line text box but I Console.Write line gives me an error.
I Tryed
<br />
Textbox1.Text = ("IP Address {0}: {1} ", i, IpA(i).ToString)& VbCrlf<br />
Any thoughts?
If there is better code out there that might also get subnet and gateway that would be great.
Thanks Heaps
<br />
'To get local address <br />
Dim sHostName As String<br />
Dim i As Integer<br />
sHostName = Dns.GetHostName()<br />
Dim ipE As IPHostEntry = Dns.GetHostByName(sHostName)<br />
Dim IpA() As IPAddress = ipE.AddressList<br />
For i = 0 To IpA.GetUpperBound(0)<br />
Console.Write("IP Address {0}: {1} ", i, IpA(i).ToString)<br />
Next<br />
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
It would have been a lot helpful if you had mentioned anything about what kind of error you get.
The call to Console.Write uses formatting, so you have to use String.Format when you want to do the same:
Textbox1.Text = String.Format("IP Address {0}: {1} ", i, IpA(i).ToString) & VbCrlf
---
b { font-weight: normal; }
|
|
|
|
|
japel wrote: Any thoughts?
First, if you get an error, tell us what it is.
japel wrote: Textbox1.Text = ("IP Address {0}: {1} ", i, IpA(i).ToString)& VbCrlf
That's never going to work. Console.Write obviously has an overload to take a formatted string.
Textbox1.Text = string.Format(
"IP Address {0}: {1} ", i, IpA(i).ToString)<br />
<br />
Will put one IP address in there. Use a string builder to build a string of multiple addresses and set that to the textbox text, using string.Format as I have done.<br />
<br />
Overall, I suggest instead of looking for code on the web, you work through a book and learn some basic programming. A basic understannding of VB.NET would have made clear to you what was happening here, that you can't format a string that way, without calling a format method ( as Console.WriteLine is doing ).<br />
<br />
Christian Graus - C++ MVP
|
|
|
|
|
Hi all,
We are migrating our web application from VS.NET 2003 to VS.NET 2005.
after migrating to 2005, it is giving two major errors for the following:
1> In HTML, withing code and at page directive: strict implisit on not allow conversion from object to string.(I tried for both on and off option)
2> for declaring Text attribute for label and other controls in HTML, its giving error: text property can not assign declarative. (I have code like: Text="Jim")
I am very much new for vs.net 2005.
i really appreciate any help on this.
Thanks,
Thampi
|
|
|
|
|
Thampi wrote: strict implisit on not allow conversion from object to string
How are you doing it ? Surely ToString will work ? You probably need to post the code...
Thampi wrote: for declaring Text attribute for label and other controls in HTML, its giving error: text property can not assign declarative. (I have code like: Text="Jim")
By HTML, I assume you mean your aspx ? I do that all the time, something sounds screwy.
Christian Graus - C++ MVP
|
|
|
|
|
Yes, I am talking about the aspx page.
But, how you are gonna use ToString in page directive? and where, and for what?
And, any way , in aspx, in html view, how we can use ToString????
I didn't get by what you are doing all the time??
If you can make me understand little bit more, that will be great?
I am very much new in vs.net 2005 and 2.0 environment.
Thanks,
Thampi.
|
|
|
|
|
Ah... you're hoping for implicit conversion and it's failing ? Again, I need to see the code to know exactly what you're doing. I imagined your object is in a <% block, and if so, you can cast in it, and call ToString()
Christian Graus - C++ MVP
|
|
|
|
|
I'm having a strange problem declaring a NEW Excel.Application. I get a blue line under the line xlApp = New Excel.Application(). When I hover over the line the error states "'New' cannot be used on an interface.". I'm a little confused with the interface reference. I have referenced Excel, and MicrosoftOffice.Core and imported them on the page. The problem code is below.
Imports Microsoft.Office
Imports Excel
Imports Microsoft.VisualBasic
Imports Microsoft.Win32
Dim xlApp As Excel.Application
Dim xlWB1 As Excel.Workbook
xlApp = New Excel.Application() <----- Line with Error "'New' cannot be used on an interface."
xlApp.Visible = True
xlWB1 = xlApp.Workbooks.Open(strPath)
xlWB1 = Nothing
I am using the same code to open Word docs and PowerPoint presentations.
Any suggestions would be very welcome.
Thanks in advance
|
|
|
|
|
Interfaces contain no implementation so there is nothing to create. Are there no examples in the documentation of how to create an Excel application?
|
|
|
|
|
Thanks Angus for your thoughts, however your suggestion did not unfortunately work. In the same sub I have created a new word.application with the following syntax:
Dim WordApp As Word.Application
WordApp = New Word.Application()
WordApp.Visible = True
WordApp.Documents.Open(strPath)
WordApp = Nothing
The syntax above works perfectly, opening the word doc.
Again thanks for your thoughts and ideas.
SL Culbertson
|
|
|
|
|
|
I can see that I can add a new element to an EXISTING object on the main form from a plugin:
Public Class Plugin
Inherits System.Windows.Forms.Form
Public Shared Sub addMenuItems(ByVal host As Object)
host.TabControl1.TabPages.Add(2, "MyName")
End Sub
But I can't see how to add a NEW control to the main form. This doesn't work, because the
button doesn't already exist on the main form (but I'm trying to CREATE it!) ???
Public Class Plugin
Inherits System.Windows.Forms.Form
Public Shared host.Button3 As System.Windows.Forms.Button
Public Shared Sub addMenuItems(ByVal host As Object)
host.Button3 = New System.Windows.Forms.Button
host.Add(host.Button3)
End Sub
TIA!
|
|
|
|
|
You want to add a button to a form ? Drag it from the toolbox.
Christian Graus - C++ MVP
|
|
|
|
|
Well I do want to place a new control -- button for instance -- on the main form. But I want to do it from a classlibrary .dll That's what I'm having trouble with. It seems easy to have the plugin (.dll) add elements to an object that already exists on the main form. But how to initially create a new control? I can't put the object on the main form ahead of time -- it needs to be done at runtime.
thanks
|
|
|
|
|
Hello, how can i download a file from web? I've made a code with WebClient (DownloadFileAsync),
the Progressbar i've realized with HttpWebRequest/Response, to get the size of the file...
But the problem is, that i can't download more files at one time. (New HttpWebRequest/Response is not possible)
Any ideas?? The applications shouldn't 'hang' when downloading, so i must work with DownloadFileAsync.
Thanks
|
|
|
|
|
softwarejaeger wrote: New HttpWebRequest/Response is not possible
Why do you think that?
---
b { font-weight: normal; }
|
|
|
|
|
It doesn't work easyily.
I get from the Debugger everytime an error.
|
|
|
|
|
Standard question #2:
What error message do you get?
---
b { font-weight: normal; }
|
|
|
|
|
The program hangs and then i get an ArgumentException Error in the Debugger, but why, what or so i don't know.
Maybe...
The Download starts in an UserControl Field, i have an list with files in a xml file and for each element, the form puts such an UserControl in a FlowLayoutPanel. In this UserControl then i have the download script. Is there any thing that couldn't be right? One download works, but a second at the same time not?!?!?!?
|
|
|
|
|
Help you with what? You haven't said anything about what the problem is!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|