|
I believe, although I am not able to access VS at the moment, so cannot be sure, there is a OnMeasureItem event that you can override to return a size that you prefer. If you look it up on MSDN I think there is a pretty good example.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I'm currently into similar issues regarding a listbox control. I guess this article[^] might help you further.
Regards
Michael
|
|
|
|
|
Thank you for your help, Michael Schäuble and Henry Minute
I will test it as fast as i can...
Edit: I tested it and it didn't work the listview has no om measureitem-Event only the listbox...
modified on Wednesday, July 15, 2009 2:33 AM
|
|
|
|
|
Hi!
I'm working on a project that involves translating C++ to VB.NET (me not really being a C++ person) and am really stuck on how to translate the following C++ to VB:
sum ^= (((UInteger)(name[i]))<<(off&0x1F));
Where "sum" in an unsigned integer, name is something that I'm not familiar with, but is declared like this:
char *name
And "off" is also an unsigned integer. Do any C++ people out there have any ideas?
Thanks!
MrWolfy
modified on Saturday, July 11, 2009 12:56 PM
|
|
|
|
|
Here's some notes that I hope might help (it's a long time since I did C++ but I think I remember it.)
char *name - declares a pointer to a char, this is a common way to access a string/array of chars. VB.Net equivalent would be a string. So name[i] is the ith char in the string.
(I'm assuming that name is a parameter or that somewhere it has been set to a valid string)
off & 0x1F - is a bitwise and of the variable off and the hex value 0x1F (31 in decimal). Effectively this gives off mod 31 (i.e. remainder after division by 31)
<< - does a left shift by whatever that mod gives. Effectively this multiplies the value in name[i] by 2 to the power of off mod 31 .
sum ^= - means that the value in sum is Xor'd with the the result of the modding and shifting.
Now how you translate that into VB is another matter.
One thing to be wary of is that the C++ is probably dealing with 8-bit chars in VB they are probably 16 bit. You need to know where the data that fills the name string is coming from and so how many bits per char.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Hi!
Thanks! I was going wrong with the "off & 0X1F" part, I had them all joined together and it gave me an error. It didn't occur to me to separate them out.
All the other information was very useful too, and has helped me in my project.
Thanks Again!
MrWolfy 
|
|
|
|
|
Just a caveat to riced's excellent answer:
Do make sure off is not 0FF (zero F F) written in lower case.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Dim name As String
sum = sum Xor ((CUInt(name.Chars(i)))<<(off And &H1F))
David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
|
|
|
|
|
Hi All,
I have generate one issue for Sending mail in Guest Account.
Access to the path 'Global\.net clr networking' is denied.
I search many posts. But nothing found. But i thing Caspol.exe is the solution for this error .
So please help me for using CASPOL.exe
thanks
If you can think then I Can.
|
|
|
|
|
This has nothing to do with programming, if the error is that you need to configure the permissions on your machine. Nor is it something that you can do in your code, to benefit an end user. I get the impression that you're more than a little lost. How are you sending emails ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I read many articles but those are provides only one solution.
Set Fulltrust Permission for ur application byusing CASPOL.exe. Which provids .net framework.
So please tell me how to set permission for my application by using CASPOL.exe.
If you can think then I Can.
|
|
|
|
|
I want to click a link in the web page
<div id="pagination" class="pagination">
<a href="http://google.com/" class="section_links" rel="me next">Next »</a>
</div>
help my
modified on Saturday, July 11, 2009 10:23 AM
|
|
|
|
|
I'm writing a program and need to design it like s sidebar, with the ability of sidebars like Google side bar and windows vista sidebar with a little different that I don't want to use gadgets. is there anyone can help? its serious.
|
|
|
|
|
Ali hojjati wrote: its serious.
But obviously not serious enough for you to google sidebar visual basic, so just how serious can it be?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I writing a program that is used for data entry for my company. On the main form there is a combo box that is full of different components we may test; things such as doors, window, closets, etc. This is list of components is store in a file in the program's directory and loaded when the program loads and all the different components are put into the combo box. This works fine. Now, when an inspector is in the field they may need to add a component not pre-programmed in. So they can go to another form and add the different components. Once they are finished enter any components they may need to add they click a command button "Done" that then saves the new components to a file:
<pre>
'Check if there are structures in the 'lstStructures' list box
If lstStructures.Items.Count > 0 Then
'Create a new file stream
Dim fs As FileStream = New FileStream(AppPath & "\" & StructureFile, FileMode.Truncate, FileAccess.Write, FileShare.None)
'Create a new stream writer
Dim Writer As StreamWriter = New StreamWriter(fs)
'Loop through each component in the 'ComponentArray' array list
For i As Integer = 0 To ComponentArray.Count - 1
'Save current component in the 'CurrentComponent' structure
CurrentComponent = ComponentArray.Item(i)
'Write the component/member string to the stream writer
'(Structure=Member1,Member2,...,MemberN)
Writer.WriteLine(CurrentComponent.ComponentStructure & "=" & CurrentComponent.ComponentMember)
Next
'Flush the stream writer
Writer.Flush()
'Close the stream writer
Writer.Close()
'Close the file stream
fs.Close()
'Close this form
Me.Hide()
End If
FL_ADDED_NEW_STRUCTURE = True
'Load the structures on the main form
frmMain.ReLoadCustoms()
</pre>
Now the <code>frmMain.ReLoadCustoms</code> should reload the file with the newly added components and add them to the combo box:
<pre>
Public Sub ReLoadCustoms()
Dim fs As FileStream
Dim Reader As StreamReader
Dim div() As String
fs = New FileStream(AppPath & "\" & StructureFile, FileMode.Open, FileAccess.Read, FileShare.None)
'Clear Component Array
ComponentArray.Clear()
'Check if the file is empty
If Not fs.Length = 0 Then
'Create a new stream reader
Reader = New StreamReader(fs)
'Read each line of the file until the end of the file
Do Until Reader.EndOfStream
'Split each line delimited with '='
'(Structure=Member1,Member2,...,MemberN)
div = Reader.ReadLine.Split("=")
CurrentComponent.ComponentStructure = div(0)
CurrentComponent.ComponentMember = div(1)
'Save the component in the 'ComponentArray' array list
ComponentArray.Add(CurrentComponent)
Loop
'Close the stream reader
Reader.Close()
'Close the file stream
fs.Close()
End If
cboStructures.Items.Clear()
For i As Integer = 0 To ComponentArray.Count - 1
CurrentComponent = ComponentArray.Item(i)
cboStructures.Items.Add(CurrentComponent.ComponentStructure)
Next
cboStructures.Items.Add("...Add...")
cboStructures.SelectedIndex = 0
cboMembers.Items.Clear()
CurrentComponent = ComponentArray.Item(0)
div = CurrentComponent.ComponentMember.Split(",")
For i As Integer = 0 To div.GetUpperBound(0)
cboMembers.Items.Add(div(i))
Next
cboMembers.SelectedIndex = 0
cboStructures.Update()
FL_ADDED_NEW_STRUCTURE = False
End Sub
</pre>
The problem is that the new components that were added do not show up in the combo box, but they are written to the file. I have verified this by looking at the component file and because the next time the program loads the new components are present...the problem is that the whole program needs to be reloaded for some reason. Any help would be greatly appreciated as this has been driving me crazy for over a month! Thanks in advanced.
P.S. The <code>ReLoadCustoms</code> sub is on <code>frmMain</code> and the <code>SaveFile</code> sub is on <code>frmStructures</code> and this is running on a PPC.
UPDATE: I have come to realize that for some reason the cboStructures.Items.Clear in the ReLoadCustoms does not actually clear the combo box. Any suggestions?
modified on Friday, July 10, 2009 2:45 PM
|
|
|
|
|
Two things occur to me.
1) at the beginning of ReLoadCustoms() you go through the StructureFile file and add each item to an ArrayList. If you run your application with a dummy StructureFile containing say 2 to 3 items, then add 1 new item, it would be relatively painless to use the debugger to watch the items being added to the list. Once you are sure that they are there you can move on to dealing with the ComboBox . Before that though you should consider using a List (Of Component) instead of an ArrayList . Look it up in the MSDN Documentation under Generics.
Also where you create the FileStream and the StreamReader , consider using a Using block. This will ensure that they are both closed and disposed properly without you having to worry about it. Something like this:
Dim div() As String
Using fs As New FileStream(AppPath & "\" & StructureFile, FileMode.Open, FileAccess.Read, FileShare.None)
'Clear Component Array
ComponentArray.Clear()
'Check if the file is empty
If Not fs.Length = 0 Then
'Create a new stream reader
Using Reader As New StreamReader(fs)
'Read each line of the file until the end of the file
Do Until Reader.EndOfStream
'Split each line delimited with '='
'(Structure=Member1,Member2,...,MemberN)
div = Reader.ReadLine.Split("=")
CurrentComponent.ComponentStructure = div(0)
CurrentComponent.ComponentMember = div(1)
'Save the component in the 'ComponentArray' array list
ComponentArray.Add(CurrentComponent)
Loop
'Close the stream reader
End Using
End If
End Using
Again look up Using in MSDN. In the MSDN Index look-up Using Statement you will see two sub items, have a read of them. It is far safer.
2) Instead of going through your ArrayList (List (Of Component) ) adding items to the Combo.Items one at a time, why not use DataBinding to bind the list to the ComboBox.DataSource . It will save you having to do all that clearing and adding. Take a look at ComboBox DataBinding Sample[^]
Please come back if I have not been clear.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
As to your first comment, I have used the debugger and have watched the items being added to the files. Also I didn't use generics because at the initial writing of this program I didn't understand them well enough and figured an ArrayList would be adequate.
As to your second comment, would I be able to use data binding with the way my ArrayList is set up? The ArrayList named ComponentArray holds a list of structures called CurrentComponent that is set up as follows:
Public Structure Component
Dim ComponentStructure as String
Dim ComponentMember as String
End Structure
The ComponentStructure may have something like "Window" while the ComponentMember has "Sash, Casing, Sill, Well." When I loop through the ArrayList I pull out the current ComponentStructure and add it to the cboStructures combo box, but the ComponentMember has to be comma delimited to get the individual members. Is this still possible using DataBinding ? Also, I tried commenting out everything after where the code clears the cboStructures combo box and seeing if the combo box items would clear (cboStructures.Items.Clear() ), and they would not. Any idea on why the combo box would not clear the items?
|
|
|
|
|
I have used the code that you originally posted to create a project. I did not alter any of your code and I put the methods on the forms that you said they belong to. Obviously I had to make some assumptions about how you did things like loading frmStructures and filling its components with data.
When I ran it I had no problems. I could add new structures and they appeared in frmMain after I clicked 'Done'. So I am not able to help with your problem in that regard.
However, I do have some suggestions, which I hope will help generally.
Your Component Structure :
1) I would suggest renaming this. .NET already has a Component class, and whilst it is not a problem at the moment, the name conflict could well bite you in the bum later.
2) For reasons that are in the next bit, I would suggest modifying it slightly:
Public Structure Component
Dim ComponentStructure As String
Dim ComponentMember As String
Public Overrides Function ToString() As String
Return Me.ComponentStructure
End Function
End Structure
Your ReloadCustoms() method:
I would suggest modifying it to be something like:
Public Sub ReLoadCustoms()
Dim fs As FileStream
Dim Reader As StreamReader
Dim div() As String
fs = New FileStream(AppPath & "\" & StructureFile, FileMode.Open, FileAccess.Read, FileShare.None)
'Clear Component Array
ComponentArray.Clear()
'Check if the file is empty
If Not fs.Length = 0 Then
'Create a new stream reader
Reader = New StreamReader(fs)
'Read each line of the file until the end of the file
Do Until Reader.EndOfStream
'Split each line delimited with '='
'(Structure=Member1,Member2,...,MemberN)
div = Reader.ReadLine.Split("=")
CurrentComponent.ComponentStructure = div(0)
CurrentComponent.ComponentMember = div(1)
'Save the component in the 'ComponentArray' array list
ComponentArray.Add(CurrentComponent)
Loop
'Close the stream reader
Reader.Close()
'Close the file stream
fs.Close()
End If
cboStructures.Items.Clear()
For i As Integer = 0 To ComponentArray.Count - 1
' <===================================================>
' <=== This is why the 'Component' structure was modified
' <=== The new ToString() method allows you to add the whole
' <=== structure to the combo, instead of just the 'ComponentStructure' string
' <===================================================>
Me.cboStructures.Items.Add(ComponentArray(i))
Next
cboStructures.Items.Add("...Add...")
cboStructures.SelectedIndex = 0
' <===================================================>
' <=== Loading cboMembers is not necessary here. That happens
' <=== in the SelectedIndexChanged handler for cboStructures (below)
' <===================================================>
cboStructures.Update()
FL_ADDED_NEW_STRUCTURE = False
End Sub
I have assumed that you handle the SelectedIndexchanged event for cboStructures. Mine looks like this:
Private Sub cboStructures_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboStructures.SelectedIndexChanged
If cboStructures.SelectedItem.ToString = "...Add..." Then
' <===================================================>
' <==== Your code for loading frmStructures
' <===================================================>
Else
' <===================================================>
' <==== because the whole 'Component' structure is in cboStructures
' <==== we can get at 'ComponentMember' easily to fill cboMembers
' <===================================================>
cboMembers.Items.Clear()
Dim comp As Component = CType(cboStructures.SelectedItem, Component)
Dim div As String() = comp.ComponentMember.Split(",")
cboMembers.Items.AddRange(div)
cboMembers.SelectedIndex = 0
End If
End Sub
Even though I was unable to replicate your problem, I hope these suggestions will be of some help to you.
Good Luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I had a vb6 project I am upgrading, in that project I had a subroutine that I used to print results such that a string of data would appear in a different column. The end result being an example as illustrated below (the 'Y's are passed as a string and this procedure wrapped them.) Not real pretty but it worked if a fixed font was used.
sample output: (the Y string is actually a series of numbers separated by commas)
XXXXX YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY ZZZZ
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYY
the code:
Sub subPrintResults(slot As Integer, toPrint As String, Result As String, qty As Integer)
Dim i As Integer
Dim chr As String
Printer.CurrentX = 2000 ' first place to results line
Printer.Print Result; ' this is the 'XXXXX in the example above
Printer.CurrentX = 3000
'if we have a long string
If Len(toPrint) > 90 Then
i = 0 ' look for last comma, starting back 1
Do Until chr = ","
chr = Mid$(toPrint, 90 - i, 1)
i = i + 1
Loop
Printer.Print Mid$(toPrint, 2, 90 - i)
Printer.CurrentX = 3000
Printer.Print Mid$(toPrint, 90 - i + 2, Len(toPrint) - 90 - i + 1);
Else
Printer.Print Mid$(toPrint, 2, Len(toPrint) - 2);
End If
Printer.CurrentX = 10000
Printer.Print Format$(qty, "@@@@@")
Exit Sub
Can anyone point me to a way to determine the length of a string in vb .net to be output so I can reproduce this type of functionality?
Thanks
No-e
edit looks like the alignment in my example was thrown off when I posted, all the YYYYs in the example should be in a single column.
|
|
|
|
|
Take a look at the Graphics.MeasureString() method.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Very cool, thanks for the pointer. I did not realize it was there. I guess this is part of my learning curve so to speak
No-e
|
|
|
|
|
Hello,
16bit applications do not show up in System.Diagnostics.Process. Is there a dotnet way to list the 16bit applications that are running?
Thank you
Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Nope. They are contained within a shell process, either NTVDM or WOWEXEC.
|
|
|
|
|
Thanks Dave,
I figured that but was hopeful. I tried to use FindWindow api to find the title of the window i'm looking for but my pc is vista (work environment is split between vista and xp) and it returns a value regardless if it finds a window with that title or not.
Is there something else more accurate I can use?
Thanks again
Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Hi All,
I've been searching for this topic for days, am I wrong or aint there alot of articles about this?
All I see and popsup everywhere is a few things "Google Earth API", "API Key", "KML" , "GE Plugin"
Can someone please help me understand this:
All I want is a VB.NET Webpage where I can enter a Adress and it navigates to it.Thats all.
What the hell is the api? Is it a DLL?
Is tha api key the same thing as a api.
I have the plugin installed.
What is KML in english please.
How do I use/call these in my code :"Google Earth API", "API Key", "KML" , "GE Plugin"
Please can anyone please please give me a usefull link or any sound advice.
Thank you guys
|
|
|
|
|