|
vbbeg wrote: Visual Basic Language Reference
String Data Type (Visual Basic)
Holds sequences of unsigned 16-bit (2-byte) code points ranging in value from 0 through 65535. Each code point, or character code, represents a single Unicode character. A string can contain from 0 to approximately 2 billion (2 ^ 31) Unicode characters.
so im guessing its not the size of the string thats the problem..
Luc didn't say it was a problem with the String type. He said it was a possible problem with GDI+ handling strings that large.
|
|
|
|
|
vbbeg wrote: for i=0 to 8000
stringtest = stringtest & "TESTING" & vbnewline
next i
so the for loop will return 8000 TESTING each with a newline in it..
[nitpicking]
That will be 8001 TESTING each with a newline in it
[/nitpicking]
|
|
|
|
|
Hi Chandra..
do you have any ideas or recommendations to help me fix this..
Thanks
Robbo
|
|
|
|
|
Hi
I am not exactly sure, but shouldn't there be a way of printing a line at a time instead of a whole page?
Chandra
|
|
|
|
|
Hey again chand
ill take any suggestions you guys have. if you have any good examples i'd appreciate it.
Regards
Robbo
|
|
|
|
|
I seem to have a problem with setting up read/write access to registry entries created in HKEY_LOCAL_MACHINE. Let me give you a little history of what I’ve been doing.
Previously, on my windows applications, I have created the applications registry entries in HKEY_CURRENT_USER. This works fine except that the registry entries are created for every user who logs on to the PC and the correct values must be maintained for every user. In reality, I want a single set of registry entries that are machine dependent and used by anyone who logs onto the PC. Therefore, I want the entries in HKEY_LOCAL_MACHINE.
Here is the code I’ve used to create the HKEY_LOCAL_MACHINE entries...
<br />
<br />
Imports Microsoft.Win32<br />
<br />
Public Class frmMain<br />
<br />
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
' Set regKey to point to HKEY_LOCAL_MACHINE<br />
regKey = Registry.LocalMachine<br />
<br />
' Create regSubKey to point to HKEY_LOCAL_MACHINE\Software\Liebert\RegistryTest<br />
regSubKey = regKey.CreateSubKey("Software\Liebert\RegistryTest", RegistryKeyPermissionCheck.ReadWriteSubTree)<br />
<br />
' Check if registry value pName exists<br />
If (regSubKey.GetValue("pName") = "") Then<br />
<br />
' If pName does not exist... then create pName entry<br />
MsgBox("User must setup registry values!", MsgBoxStyle.OkOnly)<br />
<br />
regKey.CreateSubKey("Software\Liebert\RegistryTest", RegistryKeyPermissionCheck.ReadWriteSubTree)<br />
<br />
regSubKey.SetValue("pName", txtInitPortName.Text)<br />
regSubKey.SetValue("pBaud", txtInitPortBaud.Text)<br />
<br />
' Restart the application to make use of the new value pName<br />
MsgBox("Application will restart!", MsgBoxStyle.OkOnly)<br />
<br />
End<br />
<br />
Else ' pName exists already, use it !<br />
txtPortName.Text = regSubKey.GetValue("pName")<br />
txtPortBaud.Text = regSubKey.GetValue("pBaud")<br />
End If<br />
<br />
End Sub<br />
<br />
End Class<br />
<br />
The routine checks to see if the registry entries (“pName” specifically) exist and if they do not, the code will create them. Otherwise, it simply reads the values in. Everything appears to work properly. The first time I run the application without the registry entries existing, the entries are created and the user is forced to restart the application. The registry entries are then read properly.
The textboxes txtInitPortName.Text and txtInitPortBaud.Text contain the initial values to be written to the registry if the registry entries do not exist and the textboxes txtPortName.Text and txtPortBaud.Text will contain the values of the entries that are read if the registry entries do exist.
The problem is when I logoff of the PC and have someone else logon and then try to run the application. They immediately get an exception…
Access to the registry key "HKEY_LOCAL_MACHINE\Software\Liebert\RegistryTest" is denied
The new user is able to examine the registry entries, but is unable to change them.
I thought that when I create the subKey and set the access as follows…
regKey.CreateSubKey("Software\Liebert\RegistryTest", RegistryKeyPermissionCheck.ReadWriteSubTree)
...that this would give Read/Write access to all users… obviously it doesn’t and I am doing something wrong!
Any suggestions?
|
|
|
|
|
Member 4052115 wrote: I thought that when I create the subKey and set the access as follows…
regKey.CreateSubKey("Software\Liebert\RegistryTest", RegistryKeyPermissionCheck.ReadWriteSubTree)
...that this would give Read/Write access to all users…
Wrong. What you specified was your REQUEST for access to Read/Write the subtree. You didn't GRANT those permissions.
To normal users, the entire LOCAL_MACHINE key is read-only by default. To PowerUsers and Admins, it's Read/Write. During your applications installation, you can create the root key for your app, then you have to specifically grant Read/Write permissions to that key to whatever group you want, even the built-in Everyone group.
The CreateSubTree method has a third overload where you specify the key path, the requested access control (what you specified), and then a RegistrySecurity object that sets the security on the new key. But, normal users won't have access to create the key, nor set the access permissions. Only an Admin or PowerUser can create the root key and set access permissions.
Lookup "RegistrySecurity" in MSDN Help for examples on how to use it.
|
|
|
|
|
Dave,
Thanks for the response!
I think that what I need to do is (as an Admin user) is to install the application, start it and let the code see that the registry entries do not exist which will cause them to be created and then set them to the actual values I want for all users. Then when a normal user logs on and uses the PC, the registry entries will exist and he will be able to use the application. I can see that there are a few lines to tweak, but hopefully, not a big deal.
Thanks again for your help... it is most appreciated!
|
|
|
|
|
Dave,
After reading your response, I went back and did some digging and reqrote my code. However, i still seem to be having the same basic problem. I feel like I'm dancing all around the solution, but I just am not finding it. Here is the new code...
Imports Microsoft.Win32<br />
<br />
Public Class frmMain<br />
<br />
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
' Set regKey to point to HKEY_LOCAL_MACHINE<br />
regKey = Registry.LocalMachine<br />
' Create regSubKey to point to HKEY_LOCAL_MACHINE\Software\Liebert\RegistryTest<br />
regSubKey = regKey.OpenSubKey("Software\Liebert\RegistryTest", True)<br />
' Check if registry SubKey exists<br />
If (regSubKey Is Nothing) Then ' create SubKey<br />
regSubKey = regKey.CreateSubKey("Software\Liebert\RegistryTest")<br />
regSubKey.SetValue("pName", txtInitPortName.Text)<br />
regSubKey.SetValue("pBaud", txtInitPortBaud.Text)<br />
' Restart the application to make use of the new value pName<br />
MsgBox("Registry entries created!" & vbCrLf & "Application needs restarted!", MsgBoxStyle.OkOnly)<br />
End<br />
Else ' pName exists already, use it !<br />
txtPortName.Text = regSubKey.GetValue("pName")<br />
txtPortBaud.Text = regSubKey.GetValue("pBaud")<br />
End If<br />
<br />
End Sub<br />
<br />
Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click<br />
<br />
End<br />
<br />
End Sub<br />
End Class
Again, I want my windows application to be run by myself the first time (as Admin on the machine). The application will check for the existence of the registry SubKey and if it does not exist (which it won't), it will create the SubKey (and also a couple of sample values just to see that it works. After creating the SubKey, the application will force a exit and I restart the application. This time, the registry SubKey exists and all the code does is to get the two values.
txtPortName.Text = regSubKey.GetValue("pName")
txtPortBaud.Text = regSubKey.GetValue("pBaud")
This all works fine for me as the user (Admin).
Now, I logoff and have someone else logon as a normal user. He then starts the application (the registry exists. He gets the following exception and does not read the values.
Note: I actually wanted to paste the messagebox in here for the exception, but couldn't figure out how.
Application attempted to perform an operation not allowed by the security policy. To grant this application the required permission, contact your system administrator, or use the Microsoft .NET Framework configuration tool.
If you click continue, the application will ignore the error and attampt to continue. If you click Quit, the application will quit immedately.
Requested registry access is not allowed.
In your previousmessage response, I thought that you implied that the normal user would be able to read the SubKey's values. Obviously, I'm missing something.
|
|
|
|
|
Your problem is that you're initially opening the subkey with write permissions by supplying the True argument to OpenSubKey :
' Create regSubKey to point to HKEY_LOCAL_MACHINE\Software\Liebert\RegistryTest
regSubKey = regKey.OpenSubKey("Software\Liebert\RegistryTest", True)
' Check if registry SubKey exists
If (regSubKey Is Nothing) Then ' create SubKey
and THEN you're checking to see if anything was returned. When a normal user runs that line of code, it'll fail because the user cannot open the key for write access.
Remove the True argument from that line and it'll run. Of course, you'll have to rewrite the code to find out if the key exists, then try and create the key path and values.
|
|
|
|
|
That makes sense! Hopefully, a little re-write and everything will be fine!
Thanks for all your help Dave!
|
|
|
|
|
I want to draw a graph in VB.NET.
I use visual studio 2005.
My problem is that I want to draw graph dynamically for every second
For Example: There is a person on bicycle who is going at different speeds at different times. And that data is simulated in VB
Now I want to draw a graph of speed vs time something like for fisrt second what is the speed (to be plotted on the graph) and for next second what is it and so on.
Could anyone please help me on this front.
Thank You
Edit/Delete Message
|
|
|
|
|
Google for "ZedGraph". The rest is easy, merely setting up the graph to look the way you want, then passing in the data every second. The graph draws itself.
|
|
|
|
|
Hi,
i want help in writing a savefunction in vb.net.
requirement is:
An array of hat objects is passed into the function. The hat in each object is then saved to the database table.The following properties are set in each hat object :objectID,date,quantity.
Table used is hat1
Parameter passed into the function is arrayhat which is an array of hat objects.
using .net2.0/vb.net/oracle.
Thanks
|
|
|
|
|
So what's the question?
You iterate over the collection of hat objects passed in, get the ID from the object, and check to see if it's in the database. If not, INSERT a new record in the database using the data supplied for that record. If it does exist, UPDATE the existing record. Better yet, this would probably be better suited as a stored procedure in the database. All you would have to do is pass in the 3 parameters to the procedure and it should do the appropriate checks and updates.
|
|
|
|
|
|
Hi:
My boss had selected a contractor. This was to be a "help" in my VB.Net 2005 project. The contractor was supposed to develop a sample GUI for control of an embedded box with a USB interface along with a user library. My boss requested me to provide a specification which i did.
The contractor IMHO ignored a few items in the specification. My exposure to VB.net has been part time during the past few years. What i was trying to specify was that i did not want code developed as DLL's because the delivered source code would be linkable into the main program code space and the VS.net debugger could be used to check values from the main application. I saw this as a method for development. My experience has been that the VS.Net debugger cannot directly examine the DLL code space. The contractor said we could use it this way but i have not been able to do this, does anyone have a method to do this?
Also the contractor said that the specification was confusing and that he developed the code as a DLL by mistake and that it will cost a lot of money for us to fix this. the specification section is below. (OPAL KELLY makes a USB prototype board as a commercial product and is not involved with the contract)
---------------------------------------------------------------------------------
Structure: Software routines shall be called to handle the functions locally. Software functions shall be defined in a local library for linking with discrete programs. DLL calls will be made only for linking to OPAL Kelly software or preexisting Software. The intent is to have subroutines defined that can be used with a Microsoft debugger and have “step into” capability which is not possible for DLL’s as released SW.
-----------------------------------------------------------------------------------
what are your opnions on this. I suspect i might have used better terminology but i think the intent is clear?
charlie
|
|
|
|
|
Yes, the debugger can step into .DLL code. A .DLL is just loaded as part of the process. It's no different than if the code was directly part of the .EXE's code. So long as the .DLL is a Debug build, with the debugging information shipped along with it, the debugger can step into the code with no problems.
A "local library for linking with discrete programs" screams .DLL to me. I don't see how an .EXE would fit this picture since .EXE's don't normally export library functions.
What language is this library written in?
Or did I misunderstand the situation??
|
|
|
|
|
Hi:
The Application code i am using is VB.net 2005, However the library is written in C.
From what you mentioned it looks like the debugger should be able to reference lines of code and values on that line for a "C" library.
Thanks for responding.
Charlie
|
|
|
|
|
The debugger can step into the C code base, but without debug information or the source code, you'll see the machine language representation of the code, not the original C source.
|
|
|
|
|
My project seemed simple.
1. Load a .dll into a separate appdomain
2. Use and unload it
3. Allow the user to modify the .dll via system.reflection
4. Repeat
Simply can't do it... any help appreciated. I'm working now with something like this, but it's very strange. This will not load from "c:\ma.dll" but always loads from the .dll in the current active directory instead. Also, simply cannot release the file after the unload.
Help greatly appreciated.
Dim SubDomain As AppDomain = AppDomain.CreateDomain("New Domain")
Dim s1 As FileStream = New FileStream("C:\ma.dll", FileMode.Open, FileAccess.Read)
Dim ms As MemoryStream = New MemoryStream(s1.Length)
Dim br As BinaryReader = New BinaryReader(s1)
Dim bytesRead As Byte() = br.ReadBytes(s1.Length)
ms.Write(bytesRead, 0, s1.Length)
Dim assembly As Assembly = Reflection.Assembly.ReflectionOnlyLoad(ms.ToArray)
Dim IndicatorClass = SubDomain.CreateInstanceAndUnwrap(assembly.FullName, "Indicators.Indicator")
AppDomain.Unload(SubDomain)
s1.Close()
br.Close()
ms.Dispose()
|
|
|
|
|
I've got an icon in a dropdownbox item, but it isn't in my image list. It was originally loaded from disk, but i've lost that original file. Is there any way to extract it so I can use it somewhere else?
Thanks!
|
|
|
|
|
I'm assuming all you have is the .EXE you want to pull the icon out of. Google for "ResEdit" or "Resource Editor".
|
|
|
|
|
No, I have the code itself. Should be easy I suppose, I just don't know how.
|
|
|
|
|
The image the project gets is from the image file itself. It's not stored anywhere else except cached by the IDE. If you close VS and reopen the project, the thumbnail image is reloaded from the original source file. There's no way to save the icon from the cached image you see inside the IDE.
|
|
|
|
|