|
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
|
|
|
|
|
Hi
some one give a button control which has two graphic cases ,, when mouse down , and when return up
thanks
jooooo
|
|
|
|
|
Sorry i typed the Address quickly ,, then sorry
jooooo
|
|
|
|
|
Gee, you asked so nicely...
There's probably one on the site, if not, it's very easy to write one.
Christian Graus - C++ MVP
|
|
|
|
|
Have you tried changing the Image property of the button in MouseDown and MouseUp events?
|
|
|
|
|
Hi
I need to add (INSERT) stock items to a SQL server Database of an ERP system. I import the new data from Excel and now need to change it to the correct data type before writing it to the server. In the ERP system documentation, for the stock table, they refer to 4 data types:
CHAR
INTEGER
DOUBLE
DATE
and after each data type, they have the length - E.g CHAR 3 for 3 charater text type field.
I have THREE questions:
1) Is there a way to do a SELECT statement, use DataAdapter.Fill and DataAdapter.FillSchema, and then display the datatypes of each column (i.e like ...GetType.Name.ToString or something?)
2) Is there a way to use the type information returned from the DataAdapter to set/cast the type of the data Imported from Excel before writing the new data into the database.
3) What are the VB.Net equivalent datatypes for CHAR 3, INTEGER 4, DOUBLE 6 DATE 8 etc.
PS I'm not too phased about the DATE, since this does not apply to my import, so that one is only for interest sake (and I always seem to struggle with dates...)
Cheers
Richard
|
|
|
|
|
Ok, I half answered my own question
I Created a new stock item using the ERP front end, then did a query to return this new item I have just created. I then looped through the columns as follows:
dtStkm is a the stock table, and dr2 is the row containing the new stock item.
<pre>
<code>
Dim dr2 As DataRow = dtStkm.Rows(0)
For i As Integer = 0 To dtStkm.Columns.Count - 1
dt.Rows(i).Item(0) = i
dt.Rows(i).Item(1) = dtStkm.Columns(i).ColumnName.ToString
dt.Rows(i).Item(2) = dtStkm.Rows(0).Item(i).GetType.Name.ToString
dt.Rows(i).Item(3) = dtStkm.Rows(0).Item(i).ToString.Length
dt.Rows(i).Item(4) = dtStkm.Rows(0).Item(i)
Next
Me.dgExcelData.DataSource = dt
</code>
</pre>
Questions:
1) Is the following returning the equivalent Vb.net datatype?: dtStkm.Rows(0).Item(i).GetType.Name.ToString
2) The Getype above returned 4 datatypes:
String (Many of these seem to be blank strings, but length = specified field len
DBNull
Double
Int32
DateTime
There are 187 fields in this table
2a) If I do an insert command, must I explicitly insert DBNULL for fields that are DBNULL, Explicitly insert Specific lenghts of Blank Strings for those that have blank strings. (it will be a HUGE INSERT Statment for 187 fields...)
2b) Will it be ok to use the datatypes that showed as a result of dtStkm.Rows(0).Item(i).GetType.Name.ToString.
2c) Since the I only need to populate 19 of the 187 fields with actual data, can anyone suggest an elegant way of doing this - perhaps pulling one row from the SQL server, then modifying the 19 fields, then writing that back?)
I am REALLY scared to insert somthing that may compromise the SQL database since this is our company's Live data...
Please help...
|
|
|
|
|
RichardBerry wrote: I am REALLY scared to insert somthing that may compromise the SQL database since this is our company's Live data...
This may sound totally stupid, but have you considered developing on a COPY of the database? That way you have a development/test database that looks like the live database, but you are free to completely bugger up when accidents happen (and they will happen).
RichardBerry wrote: DBNull
DBNull represents a null value in a database. The reason it does not return an actual null (or Nothing in VB.NET) is that in certain situations you need to be able to distinguish between nothing being returned and something being returned which happens to be null.
This means that the method you are using is not strictly correct becase the column that is returning DBNull may return some other type when the column contains a value.
RichardBerry wrote: (it will be a HUGE INSERT Statment for 187 fields...)
Yes, it will. You don't show how you intend to do the INSERT, but may I suggest that you use a parameterised query. That way .NET will handle the conversion between .NET types and the database types. All you have to worry about are the DBNull conversions - and that could be as easy as a method that takes an object and just returns that object unless it is null, in which case it returns DBNull.Value
RichardBerry wrote: 2c) Since the I only need to populate 19 of the 187 fields with actual data, can anyone suggest an elegant way of doing this - perhaps pulling one row from the SQL server, then modifying the 19 fields, then writing that back?)
Do you mean that each row contains pretty much the same data except for the 19 changed columns? Or do you mean that only 19 columns are populated and the rest are all null when the row is initially inserted?
If it is the latter, then may I suggest that you write an INSERT statement to just insert those 19 columns. For example, assume the following table has 20 columns, but only 3 need to be populated on insert:
INSERT TableName(Column1, Column2, Column3) VALUES (@value1, @value2, @value3)
|
|
|
|