|
QuickBooksDev wrote: If separate programs are created
A seperate project in the same solution is compiled to a library .DLL, not a seperate .EXE.
It's not different than if you added a C# Class Library project to your Solution.
|
|
|
|
|
This might help:
Sharp Serialization Library serializes and deserializes primitives, ArrayLists and Hashtables, compatible with PHP serialize().
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sharp Serialization Library did not work.
Failed in their test project on
Hashtable htFile = (Hashtable)this.serializer.Deserialize(stSerial);
Unable to cast object of type 'System.String' to type 'System.Collections.Hashtable'.
I just clicked on open. Browsed to my file with the data and that was it.
|
|
|
|
|
In a vb.net 2010 application, I am going to add a interface for a user to be able to do the following:
1. See what users are assigned to 5 specific active directory groups, and
2. allow the user to update the active directory groups.
Thus can you show me and/or point me to a url that shows me example code on how to accomplish this goal?
In an existing vb.net 2010 web form application, I am going to add an web interface for a user to be able to do the following:
1. See what users are assigned to 5 specific active directory groups, and
2. allow the user to update the active directory groups.
Thus can you show me and/or point me to a url that shows me example code on how to allow users to set the active directory groups and to update the active directory groups?
|
|
|
|
|
|
I have a problem in creating a VBA to perform a certain task. I have a data in excel which has exactly 20 rows and 1500 columns, in which 1st row of each column is the filename of a text file which has to be created in notepad. How can I copy from A2 to A20 from the first row in excel and open and paste it in a notepad and name it as (A1 value) and close it. And then again copy the 2nd row from B2 to B20 and open and paste it in a notepad and name it as the (B1 value), so on and so forth for 1500 columns. How can I program this task other than manually copying from excel and pasting it in a particular notepad. Kindly guide me
|
|
|
|
|
So... what have you tried?
This is a relatively simple task in VBA.
If you provide the code you've written, others may assist.
But do not expect anyone to simply provide the code.
|
|
|
|
|
I have tried this formula of visual basic which is as stated below
Sub writetotextfile1()
Dim rngLoopRange As Range
Open "C:\Users\Kanini\Desktop\VisualSudhu\A1.txt" For Output As #1
For Each rngLoopRange In Range("A2:A20")
Print #1, rngLoopRange
Next rngLoopRange
Close #1
End Sub
But this copies only the data range from A2:A20 and opens a notepad and pastes there and renames it as A1 and closes it and then comes back to the same worksheet of excel. I am not able to do rename it as A1(value) and I was not able to create a single macro which can run for the subsequent B2:B20, C2:C20, so on and so forth. Can you improvise this formula for me, please?
|
|
|
|
|
Hi Tim Carmichael,
I got the solution myself. Thanks for making me also believe that I can do it. I am very happy that my macro is working as per my requirement and saving me a lot of time.
Warm Regards,
R. Sudhakar
|
|
|
|
|
I am glad you worked it out for yourself.
|
|
|
|
|
Hi Tim Carmichael,
I have created a visual basic program as follows:
Sub writetotextfile1()
Dim rngLoopRange As Range
Open "C:\Users\Kanini\Desktop\VisualSudhu\A1.txt" For Output As #1
For Each rngLoopRange In Range("A1:A20")
Print #1, rngLoopRange
Next rngLoopRange
Close #1
End Sub
Sub writetotextfile2()
Dim rngLoopRange As Range
Open "C:\Users\Kanini\Desktop\VisualSudhu\A2.txt" For Output As #1
For Each rngLoopRange In Range("B1:B20")
Print #1, rngLoopRange
Next rngLoopRange
Close #1
End Sub
These are the macro created for 2 files created text format. But, I need to create it for 500 rows at a time, so that it can give me 500 text files. Is there any way that I can loop these macros and as well create a formula where in I can get 500 rows at a time. Kindly help me in this regard.
Thanks in advance,
Warm Regards,
R. Sudhakar
|
|
|
|
|
You need a loop within a loop, one for the rows and one fro the columns - something like this:
Sub writetotextfile1()
Dim iMasterLoop As Integer, iCellLoop As Integer
iMasterLoop = 1
Dim wsLoop As Worksheet
Set wsLoop = Worksheets("Sheet1")
Do While wsLoop.Cells(iMasterLoop, 1) <> ""
Open wsLoop.Cells(iMasterLoop, 1) For Output As #1
For iCellLoop = 2 To 20
Print #1, wsLoop.Cells(iMasterLoop, iCellLoop)
Next iCellLoop
Close #1
iMasterLoop = iMasterLoop + 1
Loop
End Sub
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
I'm trying to write a method that can take the path to any valid assembly and then analyze its attributes, such as title, company, and trademark, but especially custom attributes. Although I will want to get standard assembly attributes, my main purpose for this application is to get information from a custom attribute I created in another project that I add to most of my assemblies.
I have already have a method that take an assembly as a parameter and can pull the information I need. I also have a method that displays an open file dialog window where a user can select a file and then the method determines if it is a valid assembly. What I can't figure out is how to take the path to the assembly file, create an assembly object from it, and then pass it to the method that get the attributes.
He is a VERY stripped down version of the AssemblyAttributes class just to demonstrator the constructor that take an Assembly object. This class is not a concern; I have already tested all the code within this class by using the GetExecutingAssembly method and all the code worked fine:
Public Class AssemblyAttributes
Private _assembly as Assembly
Public Readonly Property Copyright as string
Get
Return GetCopyrightString
End Get
End Property
Public Sub New(assembly As Assembly)
_assembly = assembly
End Sub
End Class
And then I have my method, that gets called from a button's click event, which takes the path to an assembly (the stream writer is used later in code that is not shown to output the attribute information). This is the method where I have having trouble:
Private Sub GetAssemblyAttributes(assemblyName As String, ByRef sw As StreamWriter)
Dim currentAssembly As Assembly
Dim assemblyAttributes As New AssemblyAttributes(currentAssembly)
Dim copyright As String = assemblyAttributes.Copyright
End Sub
How can I using assemblyName to create the currentAssembly object? I have tried:
Dim currentAssembly As Assembly = Assembly.Load(name)
And got a FileLoadException and got the error message:
Could not load file or assembly 'C:\\[PathToAssembly]\\[AssemblyTryingToAnalyze].dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Next I tried:
Dim currentAssembly As Assembly = Assembly.LoadFile(name)
And got a NotSupportedException and got the error message:
An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous...
But this file is not from a network location; this code and the assembly I'm trying to analyze reside on the same computer.
Finally I tried:
Dim currentAssembly As Assembly = Assembly.LoadFrom(name)
And got the same exception and message as when I tried Assembly.Load .
I do understand the need to be caution loading 3rd-party libraries but I find it hard to imagine that there is no way to load an assembly simple to grab its attributes (such as the copyright notice, or custom attributes). I tried searching Google but every example I found only showed how to get attributes from the currently running assembly from within its own code. For example this works with the above code:
Dim currentAssembly As Assembly = Assembly.GetExecutingAssembly
So really in the end all I'm asking is, is there someway (and if so how) to get attributes from any assembly that a user make select? Thanks in advance for any help...this has been driving me crazy for the past few hours and my current project is kind of dead right now unless I can get this to work.
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
Have you tried Assembly.ReflectionOnlyLoadFrom [^]?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Wow...how did I miss that one?! I guess that is what I get for working on it till 3AM. I will take a look at that tonight when I get home. Thanks!
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
I am having trouble synchronizing the physical camera orientation with the shell orientation (must be a windows bug). Keep getting a picture stuck in landscape with I turn the MS Surface to portrait.
I have attempted to use the EXIF picture code and an appropriate method to determine shell orientation but the result is not consistent.
If anyone has found a good piece of vb.net code to do this function I would be grateful if you forward it to me.
|
|
|
|
|
Hi, I'm working on a small project , I'm trying to copy a selected list view item to a textbox this will then use the text in the textbox to create a text file with the name as the textbox text. here is the code I have so far:
If e.Button = Windows.Forms.MouseButtons.Left AndAlso e.Clicks = 1 Then
For Each selectedItem In selectedItems
REM
REM
txtITEM.Text = lsvRQLiveFeed.SelectedItems(0).Text
My.Computer.FileSystem.WriteAllText("C:\Users\Pete\Desktop\DJ Sync\DJ Sync\test\REQUEST\" + txtITEM.Text, +"." + ".txt", False)
Next
however I seem to get an error with the following line:
txtITEM.Text = lsvRQLiveFeed.SelectedItems(0).Text
InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index
is there any solution I have been working for a while on this issue and I'm struggling to find a solution ?
Any help with this greatly appreciated.
Regards
Pete
|
|
|
|
|
txtITEM.Text = selectedItem.Text
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thank you that has fixed the issue only now i need to tackle the next error:
Conversion from string "." to type 'Double' is not valid.
on this line:
My.Computer.FileSystem.WriteAllText("C:\Users\Pete\Desktop\DJ Sync\DJ Sync\test\REQUEST\" + txtITEM.Text, +"." + ".txt", False)
any ideas ?
Regards
Pete
|
|
|
|
|
Yes, it's failing on the second parameter:
, +"." + ".txt", It probably reads as 0 + "." . The second parameter is the stuff that is written to the file. If you omit the first + on that line, you'd be writing "..txt" to the file.
You might want to divide the statement over multiple lines, makes it a bit easier;
Dim sPath as String = String.Format("C:\Users\Pete\Desktop\DJ Sync\DJ Sync\test\REQUEST\{0}.txt", txtITEM.Text)
Dim sContent as String = "Whatever your content is"
My.Computer.FileSystem.WriteAllText(sPath, sContent, False) Bonus points can be earned by using the SpecialFolder enum to fetch the path to the desktop-directory, and Path.Combine to build the path.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
txtITEM.Text, +"." + ".txt", False
What's wrong there ?
You can't have a "+" next to a ","
|
|
|
|
|
I'm just trying to write a HTML text file. I can read text files, but first time writing them.
So I used the StringBuilder to build some HTML
Then I wrote a for loop to convert the stringbuilder to bytes, and then I wrote the BOM and the rest of the HTML as a file using FileStream
So I choose UT8 as the encoding, but I get the error line feed characters are inconsistent in Visual Studio when testing the file.
The original problem is when I write the file the 2nd time, and read it back, I get a BOM error, but I thought perhaps I need to fix the line feed chars first. I'm not really sure what to do here on this.
Dim m_htmlBuilder As New StringBuilder
With m_htmlBuilder
.Append("<div style=""width: " & p_width & "; Height: " & p_height & "; text-align: center; margin: 0px auto; background-color: rgb(28,134,238);"">" & vbCrLf)
.Append(" <span style=""color: rgb(255,255,255); font-size: 1.0em; font-weight: bold; line-height: " & p_height & ";"">" & vbCrLf)
.Append(p_html_name & " is now ready for use" & vbCrLf)
.Append(" </span>" & vbCrLf)
.Append("</div>" & vbCrLf)
End With
Dim m_htmlStream As String = m_htmlBuilder.ToString
Try
Dim htmlLen As Long = m_htmlStream.Length
Dim charArray As Char() = New Char(htmlLen) {}
Dim byteArray() As Byte = New Byte() {}
For cdx As Integer = 0 To htmlLen - 1
charArray(cdx) = m_htmlStream(cdx)
Dim charVal As Char = charArray(cdx)
Array.Resize(byteArray, byteArray.Length + 1)
byteArray(byteArray.Length - 1) = UTF8CharToByte(charVal)
Next
Using htmlStream = New FileStream(p_html_path, FileMode.Create, FileAccess.Write)
Using writer As BinaryWriter = New BinaryWriter(htmlStream, Encoding.UTF8)
Dim [utf8] As Encoding = Encoding.UTF8
Dim preamble As Byte() = [utf8].GetPreamble()
writer.Write(preamble)
writer.Write(byteArray, 0, byteArray.Length - 1)
If Not (writer Is Nothing) Then
writer.Close()
writer.Dispose()
End If
End Using
If Not (htmlStream Is Nothing) Then
htmlStream.Close()
htmlStream.Dispose()
End If
End Using
|
|
|
|
|
Yeah, that's doing it ........how can I put this........ the hard way.
How about using an overload of the StreamWriter class to handle all the crap for you? Oh, and you don't even have to call ToString on the StringBuilder.
Sub Main()
Dim sb As New StringBuilder()
sb.AppendFormat("Some formatted text containing {0} lines..." & Environment.NewLine, 3)
sb.AppendLine("You don't need vbCrLf at the end of every line if you use the ")
sb.AppendLine("AppendLine method of the StringBuilder instead of Append.")
Using fs As New FileStream("C:\Text.txt", FileMode.Create)
Using sw As New StreamWriter(fs, Encoding.UTF8)
sw.Write(sb)
End Using
End Using
End Sub
|
|
|
|
|
I really wanted to make that work, I'll just save it for another day. Just wanted to work with bytes for the experience.
I ended up just using 3 lines of code using textwriter before your post, but switched to your example for 5 lines and UTF8
On the read side I did the same thing in reverse. But I just changed that to the opposite of your example.
Now everything works from start to finish. Just modified everything and tested it 10 different ways.
Well thanks for the KISS, I made something really simple complex.
|
|
|
|
|
I'm writing a program in VB.NET and try to save different profiles via the application settings (project settings -> settings tab).
I created a Profile class and a collection class of that. If I choose this collection as settings type, I can add multiple objects with type System.Object, but I need to add my Profile object.
How can I add a collection of my Profile objects with the settings editor? Whats wrong with my code?
Profile.vb
Imports System.Configuration
<SettingsSerializeAs(Configuration.SettingsSerializeAs.Xml)> _
Public Class Profile
Public Property Name As String
Public Property ViewerCommand As String
Public Property ViewerPath As String
Public Property StartService As Boolean
Public Property StopService As Boolean
End Class
<SettingsSerializeAs(Configuration.SettingsSerializeAs.Xml)> _
Public Class ProfileCollection
Inherits CollectionBase
Public Shadows Function Add(ByVal ProfileObject As Profile) As Profile
MyBase.List.Add(ProfileObject)
Return ProfileObject
End Function
Public Shadows Sub Remove(ByVal ProfileObject As Profile)
MyBase.List.Remove(ProfileObject)
End Sub
End Class
A screenshot of the current behavior
The type is VNC_Manager.ProfileCollection for the setting called "Profiles".
http://i.stack.imgur.com/4Oaf8.png[^]
On the right side there should be Name, ViewerCommand, ...
If I use VNC_Manager.Profile for type, I also can't see Name, ViewerCommand... So there seems to be a problem with the Profile class(?)
|
|
|
|