|
thanks, unfortunately it doesn't. I almost had a solution where we would restart the service with the windows logon account using WMI. Unfortunaltely again, we can't find the users pwd to do that. (it works hardcoded though)
anyway, my boss wants me to try a different direction first.
Thanks.
|
|
|
|
|
Color.ToArgb() returns an Integer.
I use a color from the ColorDialog as the parameter.(pasted from the Watch window)
+ value "{Name=ff00ff01, ARGB=(255, 0, 255, 1)}" System.Drawing.Color
My tests always result in an overflow error:
"Arithmetic operation resulted in an overflow"
So, A VB.Net Color, passed to a VB.Net Color function, causes an exception?
Why would this not be a UInteger?
An Integer has a max value of about 2 billion. 256x256x256=16777216. 256x256x256x256=4294967296.
-- modified at 10:36 Wednesday 13th June, 2007
Paul Watson wrote:
Like, if you say sort of, like, you know, one more, you know, time, I'm going to, like, you know, sort of sort you out, you know.
|
|
|
|
|
What exactly are you trying to do?
"{Name=ff00ff01, ARGB=(255, 0, 255, 1)}"
This is a serailized form of a color object. Algebraic expressions cannot be used on a portion of this string. If you want to do this, then you will have to get the individual numbers using substring, store the values, and typecast the string to an int32 or use the System.Convert class.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
That was pasted from Debug. I was proving that I was passing in a valid Color argument to the function.
I can use the .A, .R, .G, .B functions to get individual values, and rebuild it, but there is this .ToArgb function provided by Microsoft, why not use it?
My point is an Int32 cannot possibly hold the value. ColorDialog returns every color with an Alpha of 255 (ie Red=255, 255, 0, 0).
Paul Watson wrote:
Like, if you say sort of, like, you know, one more, you know, time, I'm going to, like, you know, sort of sort you out, you know.
|
|
|
|
|
Yes, it can. An ARGB color returns a full 32-bits, 4 bytes, 8-bit values for each. An Integer, or System.Int32 in the .NET Framework, is a signed 32-bit integer. An UNSIGNED 32-bit value, System.UInt32, is the exact same size and can hold the same bytes. What's different between the two, how this relates to the value returned by ToArgb, is the interpretation of those bits.
In the unsigned interpretation, all the bits are interpreted as a positive value, the range being 0 (0x0000 0000) to 4,294,967,295 (0xFFFF FFFF).
The signed interpretation of those same bits is a little different. The most significant bit (far left) is reserved for the sign of the number. This bit is turned on if the number is negative, off if positive. So, the range of numbers is -2,147,483,648 (0x8000 0000) to 2,147,483,647 (0x7FFF FFFF).
Both support the full range of 4,294,967,295 values. It's all in the way you look at them.
So, ToArgb CAN return all those color values in an Integer. It's just half the numbers returned will be negative numbers.
|
|
|
|
|
Dave Kreskowiak wrote: So, ToArgb CAN return all those color values in an Integer
Only if the A value is low enough to NOT CAUSE AN OVERFLOW.
Paul Watson wrote:
Like, if you say sort of, like, you know, one more, you know, time, I'm going to, like, you know, sort of sort you out, you know.
|
|
|
|
|
Richard Jones wrote: Only if the A value is low enough to NOT CAUSE AN OVERFLOW.
Strange, it works perfectly fine for me:
For A As Integer = 0 To 255
Dim mycolor As Color = Color.FromArgb(A, 255, 255, 255)
Dim x As Integer = mycolor.ToArgb()
Console.WriteLine(x)
Next
Now, if you do any math on the very large values returned by ToArbg, such as adding a value to it, that can cause an overflow. The ToArbg method itself cannot cause an overflow.
|
|
|
|
|
My apologies. You are correct. I tried your code.
Then I changed my function from
value = colordialog.color
ColorToInteger = value.ToArgb()
to
value = colordialog.color
dim x as integer = value.ToArgb()
and it works as well.
ColorToInteger = x <-- overflow
My problem was my Function was returning a UInteger (which is what I need), and that was causing the overflow.
I wonder if there's a way to convert the Integer to UInteger.
Paul Watson wrote:
Like, if you say sort of, like, you know, one more, you know, time, I'm going to, like, you know, sort of sort you out, you know.
|
|
|
|
|
Not is a useful sense. Negative Integers don't have a defined conversion to an Unsigned Integer. You can use the Convert class and it's ToUInt32 method, but it will throw an Overflow exception if the Int32 value is less than 0.
' This will bomb out...
Dim myUInt As UInt32 = Convert.ToUInt32(-400)
It can, however be done using two conversions and the BitConverter[^] class.
Dim bytes As Byte() = BitConverter.GetBytes(someInt32)
Dim myUInt32 As UInt32 = BitConverter.ToUInt32(bytes, 0)
But, like I said, this conversion doesn't have any defined meaning.
|
|
|
|
|
Thanks. I'll just stick to the long method (.R, .G, .B).
Paul Watson wrote:
Like, if you say sort of, like, you know, one more, you know, time, I'm going to, like, you know, sort of sort you out, you know.
|
|
|
|
|
Thomas Stockwell wrote: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
That's about right
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hi,
Background:
Plugin Application.
TestPlugin.exe file is loaded into the main program using reflection. (this works)
Main program calls "ShowConfig()" plugin function using reflection invoke(obj, args),
and the plugin displays the config window,
user sets his config, clicks OK, window disappears
showconfig() passes back a reference to the "TestConfigObj" in the args
TestConfigObj is also public inside the TestPlugin.exe assembly.
Looking at the "args(0)" - it correctly shows the TestConfigObj.myconfigvars
Main Test program now wishes to take a clone of this "object"
BUT
this code is throwing this exception when I try and clone the "object",
<br />
Function ObjectCopy(ByVal obj As Object, ByVal AssemblyFileName As String) As Object<br />
'copies original object to stream then <br />
'deserializes that stream and returns the output<br />
'to create clone (copy) of object<br />
<br />
Dim objMemStream As New MemoryStream(5000)<br />
Dim objBinaryFormatter As New BinaryFormatter(Nothing, _<br />
New StreamingContext(StreamingContextStates.Clone))<br />
<br />
' make sure our assembly is loaded!<br />
' System.Reflection.Assembly.LoadFile(AssemblyFileName)<br />
<br />
' output the object, reset pointer and input the object back again<br />
objBinaryFormatter.Serialize(objMemStream, obj) ' *** THIS LINE(1) IS OK - Mouse hover shows ME ASSEMBLY BREAKDOWN OF 'Obj'<br />
objMemStream.Seek(0, SeekOrigin.Begin)<br />
ObjectCopy = objBinaryFormatter.Deserialize(objMemStream) ' *** THIS LINE(2) THROWS UNKNOWN ASSEMBLY<br />
<br />
objMemStream.Close()<br />
end Function<br />
Exception:
<br />
System.Runtime.Serialization.SerializationException was unhandled<br />
Message="Unable to find assembly 'CTPTestDemo1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."<br />
Source="mscorlib"<br />
StackTrace:<br />
at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()<br />
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)<br />
at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] <br />
...<br />
However, when I hover the mouse over line(1) 'obj' I get:
<br />
- obj | { CTPTestDemo1.TestConfigObj }<br />
- CTPTestDemo1.TestConfigObj | { CTPTestDemo1.TestConfigObj }<br />
- Iterations | 12345<br />
I have tried loading the CTPTestDemo1 assembly just before I serialize, but this doesn't work
(hence why I have commented it out again)
Why can the mouse hover give me the correct "TestConfigObj" details, and serialize it,
but can't deserialize it back into the new object?
I have gone through the GetReferencedAssemblies() but the CTPTestDemo assembled is not listed in this collection.
I also only have ONE version of the CTPTestDemo assmebly (.exe file)
I do not want to reference in the MainApps References the TestPlugin.Exe Assembly - as these are test Plugin's and so the mainapp should not need to know about them
Any Ideas would be greatfully received!
Thanks,
Phil.
|
|
|
|
|
Hi,my problem is my project was developed in asp.net with c# but my visual source safe schedular is working on windows.In vss i have all the document files,pdf files,excel files.It's starts working on everyday night 12.00am.so while schedular running time doc files,pdf files,excel files phisical path is converted to html path(/).So sometimes if any document file has any problem the vss is stopped upto that document afterthat it doesn't continue.So what i want is if any document file has problem then schedular ignores that document and it goes to next document.iam sending some classes in my vss.
<pre>
public function get vss connection()
Public Function PopulateProject() As Boolean
Private Function PopulateSubProject(ByVal sParent As String, ByVal ItemIsDeleted As Boolean) As Boolean
Private Function Traverse(ByVal sProjectPath As String, ByVal SWFPath As String)
Private Function PopulateFiles(ByVal sParentID As Long, ByVal sProjectPath As String, ByVal sFolderPath As String) As Boolean
Private Sub InsertMenuRights()
Private Sub InsertDocNames()
Private Sub CreateFolder(ByVal Path As String)
Private Function GetNWExt(ByVal FileName As String) As String
Public Sub Conversion()
Private Function GetHTMLPath(ByVal FilePath As String)
Private Sub DocToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Sub PptToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Sub PDFToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Sub ExcelToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Function GetTPath(ByVal DocPath As String)
Private Function GetTruncPath(ByVal HTMPath As String)
</pre>
samrama
|
|
|
|
|
Is there a particular reason you posted the same question four times today? Do you think that will get people to help you?
______________________
stuff + cats = awesome
|
|
|
|
|
leckey wrote: stuff + cats = awesome
I don't know why but I read that as "stuffed cats = awesome"
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Ah, that would not be the same thing! (It's from stuffonmycat.com.) I did want to taxidermy my cat Boomer when he dies, but now I'm trying to convince my husband to clone him.
______________________
stuff + cats = awesome
|
|
|
|
|
Hi,my problem is my project was developed in asp.net with c# but my visual source safe schedular is working on windows.In vss i have all the document files,pdf files,excel files.It's starts working on everyday night 12.00am.so while schedular running time doc files,pdf files,excel files phisical path is converted to html path(/).So sometimes if any document file has any problem the is stopped upto that document afterthat it doesn't continue.So what i want is if any document file has problem then schedular ignores that document and it goes to next document.iam sending some classes in my vss.
<pre>
public function get vss connection()
Public Function PopulateProject() As Boolean
Private Function PopulateSubProject(ByVal sParent As String, ByVal ItemIsDeleted As Boolean) As Boolean
Private Function Traverse(ByVal sProjectPath As String, ByVal SWFPath As String)
Private Function PopulateFiles(ByVal sParentID As Long, ByVal sProjectPath As String, ByVal sFolderPath As String) As Boolean
Private Sub InsertMenuRights()
Private Sub InsertDocNames()
Private Sub CreateFolder(ByVal Path As String)
Private Function GetNWExt(ByVal FileName As String) As String
Public Sub Conversion()
Private Function GetHTMLPath(ByVal FilePath As String)
Private Sub DocToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Sub PptToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Sub PDFToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Sub ExcelToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Function GetTPath(ByVal DocPath As String)
Private Function GetTruncPath(ByVal HTMPath As String)
</pre>
samrama
|
|
|
|
|
Hi,my problem is my project was developed in asp.net with c# but my visual source safe schedular is working on windows.In vss i have all the document files,pdf files,excel files.It's starts working on everyday night 12.00am.so while schedular running time doc files,pdf files,excel files phisical path is converted to html path(/).So sometimes if any document file has any problem the is stopped upto that document afterthat it doesn't continue.So what i want is if any document file has problem then schedular ignores that document and it goes to next document.iam sending some classes in my vss.
<pre>
public function get vss connection()
Public Function PopulateProject() As Boolean
Private Function PopulateSubProject(ByVal sParent As String, ByVal ItemIsDeleted As Boolean) As Boolean
Private Function Traverse(ByVal sProjectPath As String, ByVal SWFPath As String)
Private Function PopulateFiles(ByVal sParentID As Long, ByVal sProjectPath As String, ByVal sFolderPath As String) As Boolean
Private Sub InsertMenuRights()
Private Sub InsertDocNames()
Private Sub CreateFolder(ByVal Path As String)
Private Function GetNWExt(ByVal FileName As String) As String
Public Sub Conversion()
Private Function GetHTMLPath(ByVal FilePath As String)
Private Sub DocToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Sub PptToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Sub PDFToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Sub ExcelToHTML(ByVal FilePath As String, ByVal HTMLPath As String)
Private Function GetTPath(ByVal DocPath As String)
Private Function GetTruncPath(ByVal HTMPath As String)
</pre>
samrama
|
|
|
|
|
You had already asked the same question 6 hours back and when someone knows the answer to it, they will answer. Delete your duplicate posts.
|
|
|
|
|
Hi,
I need to create a path for where my XML needs to be saved, but I need to get the path where the web files are saved on the server. In classic ASP I think I used Server.MapPath or something like that. The reason why I don't want to hard code is because certain hosting companies save the website on the C: drive, or f: Drive, etc.
Please can someone help? I'm using VB.NET 1.1.
Regards
ma se
|
|
|
|
|
hi,
the same works in asp.net as well
if it is a windows application use: "Application.StartupPath"
regards
|
|
|
|
|
It's a web application, how would I do it now??
|
|
|
|
|
System.AppDomain.CurrentDomain.BaseDirectory.ToString
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hi,
If I take a combobox on form, what I want is I want to store data selected from combobox to database. Take for example.
Combobox has 3 options-->>1)Mr. 2)Mrs. 3)Miss
Now what I want is if i select any one option from this it should
be stored in my data base(Access).
How to write a query for this, which event i should take on combobox.
Do I need 2 tables for this. I mean one for their details and one for Mr.,Mrs,Miss
Please solve my query
-- modified at 7:45 Tuesday 12th June, 2007
Nitin Jenwal
|
|
|
|
|
You can handle a selected index changed event. How you handle it depends on if you want to write your record again for every field that changes, or if you want a save button.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|