|
wildcard
(Thursday, December 23, 2004)
Found the following interesting discussion in the Newsgroups:
wildcard by:Anonymous
| vb windows .net 2002 crystal reports 9
Record selection formula works fine for currency string result, good for operators =/>= and so on, as follows: vb form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim SelectFormula As String Dim myCrystalReportViewer = CrystalReportViewer1 SelectFormula = "{CLIN_FUND.FUND_AMT} > " & TextBox1().Text CrystalReportViewer1.SelectionFormula = SelectFormula ......etc
crystal select formula ... {CLIN_FUND.FUND_AMT} > 500.00; ==========
Now, I'm using a string for a description, and as long as it equals what's in the textbox (= or LIKE), it's fine. But I need to use a wildcard to pull in all results that would contain what the user types in the textbox and it's not working.
vb form
SelectFormula = "{LINE_ITEM.CLIN_DESC} LIKE '" & TextBox1().Text & "'" CrystalReportViewer1.SelectionFormula = SelectFormula
crystal formula {LINE_ITEM.CLIN_DESC} LIKE "%%";
I tried inserting a wildcard % in the vb statement, but no luck.
How do I pull in all results that include the user's input in the textbox, please?
Many thanks.
-H
| | | Reply: by:Bernie Yaeger
| | | Hi Helen,
Here's the syntax as it should appear inside crystal:
{prod.bipad} like "187". If the user enters 'an' against a list of names, this will return nancy, danny, but not bernie and not helen.
HTH,
Bernie Yaeger
| | | Reply: by:Anonymous
| | | Thank you, Bernie. I even got it to work with your scenario, but with a wildcard instead, such as {prod.bipad} like "%%", so it's up and running now and lookin' good. Working for text strings, and multiple fields from multiple tables, but not yet working for string containing numericals. I have a separate posting for this question. Hope to resolve v. soon. -H
|
Posted by Xander Zelders

COM wrapper around a .NET assembly
Found the following interesting discussion in the Newsgroups:
COM wrapper around a .NET assembly by:Graham Blandford
| Hi all,
Wonder if anyone can point me in the right direction.
Due to time-constraints, it looks lie I may have to abandon using VB.NET development in favour of my more familiar VB6 environment. The issue I have is, that I have to use a .NET assembly (DLL) to access data from a database.
I understand it is possible to create a wrapper using COM which would then make it available to VB6. Although this isnt ideal, it might help me, in this partiular case, get to where I need to go a lot quicker. I'm not familiar with COM, but it may still be less of a learning curve than ..NET....
Any help would be happily received.
Thanks, Graham
| | | Reply: by:JLW
| | | Do a Google for COM Interop with VB.NET, you can compile your assembly to act as an ActiveX COM object that VB6 can use without a problem.
HTH JLW
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | <URL:http://msdn.microsoft.com/library/en-us/cpguide/html/cpconexposingnetframeworkcomponentstocom.asp> <URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconCOMInteroperability.asp>
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
| | | Reply: by:Val Mazur
| | | Hi Graham,
Check next KBs about it
http://support.microsoft.com/default.aspx?scid=kb;en-us;817248&Product=vb6
http://support.microsoft.com/default.aspx?scid=kb;en-us;317535
-- Val Mazur Microsoft MVP
|
Posted by Xander Zelders

More data woes....
Found the following interesting discussion in the Newsgroups:
More data woes.... by:Graham Blandford
| Hi all,
Well I abandoned the use of a datagrid in my windows form and have opted to use a listbox instead.
I have, following a helpful article created an item class and loaded it with values from an ADO recordset.
Now, if I read the data I get a field (clientid) looking like this;
{FE84ACD5-8263-11D7-B0E7-0080AE000001}
when in fact, the actual data (as viewed using say a binding to a datagrid) looks like this;
fe84acd5-8263-11d7-b0e7-0080ae000001
Why is it placing {} around the string and CASING up? AAARRRRGGGHHHH!!
Here's some code snippets - where could this be happening?
By the way - I'm forced to use ADO as the dataaccess method in this case - it is pulled from a 3rd-party reference which returns an ADO recordset. I guess I could load the data into a dataset prior to reading - but then I'm not sure how I read through the set sequentially.....
The defined class:-
Private clientid As String Private Class ClientListItem Private clientid As String Private clientname As String Public Sub New(ByVal id As String, ByVal name As String) clientid = id clientname = name End Sub Public Property listclientid() As String Get Return clientid End Get Set(ByVal Value As String) clientid = Value End Set End Property Public Property listclientname() As String Get Return clientname End Get Set(ByVal Value As String) clientname = Value End Set End Property Public Overrides Function ToString() As String ' this can be whatever you want to show in the listbox Return clientname & " " & clientid End Function End Class And here's the loading of the data into the listbox; If rsclients.State <> ADODB.ObjectStateEnum.adStateClosed Then rsclients.MoveFirst() While Not rsclients.EOF id = Trim(rsclients.Fields(0).Value) name = rsclients.Fields("clientname").Value ' Debug.WriteLine(rsclients.Fields("clientid").Value & " " & rsclients.Fields("clientname").Value) ' Debug.WriteLine(id.ToString & " " & name.ToString) Dim liclients As New ClientListItem(id.ToString, name.ToString) lstClients.Items.Add(liclients) rsclients.MoveNext() End While End If If anyone has any ideas I'd appreciate it.
Thanks, Graham
| | | Reply: by:Graham Blandford
| | | Ok.. Ok... yep.. I got it... GUID.....
Thanks, for anyone that already took the time to reply......
Graham
| | | Reply: by:CJ Taylor
| | | Datagrid columns will call the ToString() method of the datatype (which all have in .NET since they all derive from object). Thats how you get your display
In your case, your using a GUID which when calling the ToString() removes the {}'s
|
Posted by Xander Zelders

Serial Communication
Found the following interesting discussion in the Newsgroups:
Serial Communication by:André Almeida Maldonado
| Hey Guys, I need to send some text to the COM 1 port. How can I do it??????? Thank's
| | | Reply: by:Charles Law
| | | Hi André
If you want VB.NET code you could look here:
http://www.codeworks.it/net/VBNetRs232.htm
It is a very good starting point.
HTH
Charles André Almeida Maldonado wrote: > Hey Guys, I need to send some text to the COM 1 port. How can I do > it??????? > > > Thank's
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | Thomas Scheidegger's Serial Port FAQ (in German) <URL:http://groups.google.com/groups?selm=O2UyhTLvDHA.1680%40TK2MSFTNGP12.phx.gbl>
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders

VB and 'graphical' languages
Found the following interesting discussion in the Newsgroups:
VB and 'graphical' languages by:FE-FR
| Hi,
I know that I am in a .net newsgroup, but you probably advise me.
I must use VB6 for a small tool. I need to display an information in a graphical language (hebrew, arabic, ...).
As a test, I would like to display HELLO on the screen in English and hebrew. For example, use a LABEL control.
If I select the DAVID font, ... how can I display the caracters I need ?
If I use the 'insert symbol' option in Winword, I can see that graphical caracters are for example 05D2h (1488). How can I use this with a LABEL control in VB6 ?
Thanks for your help
FE
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | VB6 controls do not support Unicode. If you want to support unicode in UIs, I would use .NET.
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders

Custom Control Postback Problems
Found the following interesting discussion in the Newsgroups:
Custom Control Postback Problems by:BluDog
| Hi
I have a created a custom web control called ImageBrowser, extract is below:
<Code>
#Region "Properties"
Public Property Images() As ImageCollection Get If ViewState("Images") Is Nothing Then ViewState("Images") = New ImageCollection End if Return CType(ViewState("Images"), GalleryImageCollection) End Get Set(ByVal Value As ImageCollection) ViewState("Images") = Value End Set End Property
Public Property CurrentImage() As Integer Get Return CInt(ViewState("CurrentImage")) End Get Set(ByVal Value As Integer) ViewState("CurrentImage") = Value End Set End Property
#End Region
#Region "Initilization"
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
If Not IsPostBack Then GetData() 'populates Images collection from database
AddImages()
End Sub
Private Sub AddImages
Dim Image as WebControls.Image Dim ImageCounter as Integer For Each Image in Images Dim ImageButton as New WebControls.ImageButton ImageButton.ImageUrl = Image.ImageUrl ImageButton.ID = "Image" & ImageCounter.ToString Me.Controls.Add(ImageButton) AddHandler ImageButton.Click, AddressOf Image_Click ImageCounter += 1 Next
End Sub
#End Region
#Region "Implementation"
Private Sub Image_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Dim ImageName As String = CType(sender, ImageButton).ID CurrentImage = CInt(ImageName.Substring(5))
End Sub
#End Region
</Code>
Within the AddImages function each image in the Images collection is added to the control as an ImageButton, I have to do this in the prerender because i need to know what the CurrentImage property is from the ViewState and this in the first place i have found it to be populated.
The only problem is that the event for the ImageButton.Click is not firing, i believe this is because i have added it to late in the page life cycle. This appears to be a but of a nasty circle. Does anyone know where i am going wrong?
Thanks
Blu
| | | Reply: by:Raterus
| | | Eww..
Yeah I think you know your problem already, you need to call AddImages from page_load and not PreRender. By PreRender it is one step too late to process Handlers, as that step just passed.
Here is a good article on the ASP.NET page lifecycle, it may help understanding when viewstate gets populated, I don't see why you couldn't do it in page_load, perhaps you could share your problems when you try that next.
http://www.15seconds.com/Issue/020102.htm
Happy Coding! --Michael
|
Posted by Xander Zelders

[Help] my form lost my Tab page1 & page 2.
Found the following interesting discussion in the Newsgroups:
[Help] my form lost my Tab page1 & page 2. by:Agnes
| In design mode, i didn't see my tab page1 & page2, however, in view code, I see all my textbox object and tab page 1& page2, What's going on ??? I design my form again and again ???? Please help
| | | Reply: by:Carl Rapson
| | | Is the Tab control's Style property set to "None" instead of "Tabs"?
Carl Rapson
| | | Reply: by:Agnes
| | | Tab Control's Style property ?? I can't find such property , where is it ?? Thanks From agnes
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | Is this problem related to the issue you described in another post (controls not showing up after doing an update of a DLL file)?
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders

[HELP] All textbox and button disappear in design mode
Found the following interesting discussion in the Newsgroups:
[HELP] All textbox and button disappear in design mode by:Agnes
| I got form A which inhertied from frmBASE Todays, i had re-arrange our usercontrol or other class library. (re-build them) suddenly, i found all some forms 's textbox and button disappear in desgin mode. As I run them, I still can see the textbox, BUT nothing can be seems in design mode, How come ??? It is not my first time, PLEASE HELP!!! thanks From Agnes
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | Have a look if there is a call to 'Me.Controls.AddRange(...)' in the form's 'Sub InitializeComponent' that adds all the controls to the form.
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders

Problems with ListAvailableSQLServers (SQLDMO)
Found the following interesting discussion in the Newsgroups:
Problems with ListAvailableSQLServers (SQLDMO) by:Craig G
| i have the following code in a form load event, that (should) simply populate a combobox with the names of all SQL servers on the network
Dim x As Long Dim sqlNameList As SQLDMO.NameList
'Filling Servers Name
sqlNameList = sqlApp.ListAvailableSQLServers
For x = 1 To sqlNameList.Count
cbo_Server.Items.Add(UCase(sqlNameList.Item(x)))
Next Me.Show()
but it falls over on the ListAvailableServers, with the following error
"QueryInterface for interface SQLDMO.NameList failed."
im pretty new to this .net (vb6 previously) so i dont know what is wrong
any idea's??
Cheers, Craig
| | | Reply: by:Patrick Steele [MVP]
| | | In article <etGzikLREHA.1348@TK2MSFTNGP12.phx.gbl>, Gambit001 @hotmail.com says... > "QueryInterface for interface SQLDMO.NameList failed."
If you're running SQL2000, make sure SP2 is installed. This was a known bug fixed in SP2.
-- Patrick Steele Microsoft .NET MVP http://weblogs.asp.net/psteele
|
Posted by Xander Zelders

debuging web controls
Found the following interesting discussion in the Newsgroups:
debuging web controls by:Vincent Finn
| Hi,
I have some controls (VB.Net) written be someone else They are loaded using an asp page
How can I debug the contol? I have tried attaching the process to IExplorer and aspnet_wp.exe but I get nothing, no breakpoints are hit
I have also tried setting the "Start URL" in the project to the correct page but it simple displays a message box saying "Error while trying to run project"
I assume it is something simple but I can't find it in the MSDN or on the web
Vin
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | Do you have the source code of the controls?
-- Herfried K. Wagner [MVP]
| | | Reply: by:Vincent Finn
| | | I do I have been trying to attach from the project that builds the controls
I the debugging tab I have it set with a "Start URL" and ASP.Net debugging enabled In the build tab I am generating debug information
but when I run it, it tells me that the project isn't configured to be debugged
Vin
|
Posted by Xander Zelders

Microsoft.Office.Interop.Excel
Found the following interesting discussion in the Newsgroups:
Microsoft.Office.Interop.Excel by:©pEIO
| Example:
Dim xlsExcel As Excel.Application Dim wkbExcel As Excel.Workbook Dim wksExcel As Excel.Worksheet
xlsExcel = New Excel.Application wkbExcel = xlsExcel.Workbooks.Open("C:\Test.xls") wksExcel = wkbExcel.Worksheets(i)
In this point I have an error of conversion because Option Strict On can't convert System.Object in Microsoft.Office.Interop.Excel.Worksheet. It's very strange because before that I install the PIA for Office 2003, the object wkbExcel.Worksheets(i) was an Microsoft.Office.Interop.Excel.Worksheet object. But I have resolved with this:
wksExcel = CType(wkbExcel.Worksheets(i), Excel.Worksheet) MessageBox.Show(CType(wksExcel.Cells(6, 1), String))
In the last istruction an exception occurred. The message like this "Cast not possible from Range type to String type". I have try with the MSDN example but the same exception occurred.
Somebody have some idea?? I'm crazy...
Thanks. Ciao. pEIO
| | | Reply: by:Armin Zingler
| | | As the message says, a Range object is returned:
dim r as excel.range
r = directcast(wksExcel.Cells(6, 1), excel.range)
msgbox(r.value) -- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
| | | Reply: by:©pEIO
| | | Very thanks Armin. But why in the PIA of Excel the wksExcel.Cells(6, 1) are declare Object and not Excel.Range???
Thanks. Ciao. pEIO
| | | Reply: by:Armin Zingler
| | | | The type of the Cells property itself returns a Range object (see the object browser). "wksExcel.Cells(6, 1)" is actually "wksExcel.Cells.Item(6, 1)", but I don't know why the type of the Item property is not "Range" although it always returns a Range object. This might be answered in an Excel VBA group.
-- Armin
Posted by Xander Zelders

Double-click event in datagrid?
Found the following interesting discussion in the Newsgroups:
Double-click event in datagrid? by:Graham Blandford
| Hi all,
Can anyone tell me how I can detect the double_click event in a datagrid CELL. I have a read-only bound grid that appears to only receive the event if you double_click the header or in between a row...
I'm basically trying to retrieve the value of the underlying row to retrieve a record selection.
Any help would be appreciated.
Thanks, Graham
| | | Reply: by:Cor Ligthert
| | | Hi Graham,
You can try to use a textbox in the datagrid and than use the event from that.
I made once a sample with a tooltip in the datagrid column so maybe you can change that yourself and try if it works.
I hope this helps?
Cor
\\Private WithEvents dtbCol1 As DataGridTextBox Private ToolTip1 As New ToolTip ') Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Datagrid1.ReadOnly = True Dim ts As New DataGridTableStyle ts.MappingName = ds.Tables(0).TableName Dim column As New DataGridTextBoxColumn ts.GridColumnStyles.Add(column) DataGrid1.TableStyles.Add(ts) column = DirectCast(ts.GridColumnStyles(0), DataGridTextBoxColumn) dtbCol1 = DirectCast(column.TextBox, DataGridTextBox) column.MappingName = ds.Tables(0).Columns(0).ColumnName column.HeaderText = "Cor" column.Width = 30 dv = New DataView(ds.Tables(0)) dv.AllowNew = False DataGrid1.DataSource = dv End Sub Private Sub dtbCol1_ToolTip(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles dtbCol1.MouseEnter ToolTip1.SetToolTip(DirectCast(sender, DataGridTextBox), _ "Row: " & DataGrid1.CurrentRowIndex + 1) End Sub ///
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q869q
Ken
|
Posted by Xander Zelders

Catching "Came from Row" on a RowChange in Datagrid?
Found the following interesting discussion in the Newsgroups:
Catching "Came from Row" on a RowChange in Datagrid? by:Lars Netzel
| I need to capture some sort of a rowchange (or datasource row change) and what I need in that Event is info from the row I came from not the row I'm changing to... a tricky for me.. I have no idea of what Object I should be looking for events for.
Best Regards /Lars
| | | Reply: by:Cor Ligthert
| | | Hi Lars,
Please stay in the same thread in this way answering becomes impossible.
I have made an answer there.
Cor
|
Posted by Xander Zelders

Delete Option on a Right Click Menu?
Found the following interesting discussion in the Newsgroups:
Delete Option on a Right Click Menu? by:Lars Netzel
| Hey!
I need to make it possible for a user to delete items from a ListView. I want it to be as similar to Windows as possible so I want it to happen if I press Delete or with a RightClick menu with a delete option.
I have no idea on how to fix any of the two.. where do I start?
/Lars
| | | Reply: by:Lars Netzel
| | | Oh, it was simple... sorry for wasting your time!
/Lars
|
Posted by Xander Zelders

How to open a new browser
Found the following interesting discussion in the Newsgroups:
How to open a new browser by:Anonymous
| Hi, I used the following code to open a browser:
System.Diagnostics.Process.Start(url)
however, it took the latest activate opened browser (if exists already). I'd like to know how to open such web page in a new browser A, and every time I run the code again, the web page must be opened only in this browser A.
Thanks in advance
| | | Reply: by:William Ryan eMVP
| | | Try Process.Start("iexplore.exe", url)
-- W.G. Ryan MVP Windows - Embedded
http://forums.devbuzz.com http://www.knowdotnet.com/dataaccess.html http://www.msmvps.com/williamryan/
| | | Reply: by:Anonymous
| | | Thanks William,
It works fine. How about the situation for checking if the browser is already openned?
|
Posted by Xander Zelders

Opening an existing file on my PC
Found the following interesting discussion in the Newsgroups:
Opening an existing file on my PC by:LB
| I have one form that has two buttons. I want the first button to exit the form, and the second button to open a specific file on my C: drive.
I can get the form to close (Woo!), but can anybody tell me the code needed to open an existing file on my computer. I've spent all morning looking on the net but have had no luck.
The file, if it makes any difference, is a .pps
Thanks in advance people.
Luke
| | | Reply: by:Cor Ligthert
| | | Hi Luke,
Can you try this one
\\Dim p As New System.Diagnostics.ProcessStartInfo() p.FileName = "C:\filename.pps" p.UseShellExecute = True System.Diagnostics.Process.Start(p) ///
Cor
| | | Reply: by:Hal Rosser
| | | Try using the System.IO.StreamReader class dim sr as System.IO.Streamreader sr = new System.IO.StreamReader("theFileName.pps")
assuming you want to read the file --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.690 / Virus Database: 451 - Release Date: 5/22/2004
|
Posted by Xander Zelders

Convert charref ({) to normal letters
Found the following interesting discussion in the Newsgroups:
Convert charref ({) to normal letters by:Daniel Köster
| Hi I asked this question a couple of days ago as well but I didn't get any answers that I could use.
Is there someone who has got som tips on how to convert text encoded with character referense ({) to unicode or uft-8 format using VB.net? Is there a function or something that can help with the conversion?
To use a simple replace "this" with "that" is not an option since there are som asian-texts that I need to convert as well. (chinese, thai and japanese; the replace list would be to large to handle)
What i want to do is to be able to compare a file coded with character references (i.e. {) with a file coded with normal unicode characters (i.e. ö,ä,å)
Best regards Daniel
| | | Reply: by:Cor Ligthert
| | | Hi Daniel,
These questions like yours in the dotnet newsgroups are mostly answered by Jay B. Harlow, however even more by Jon Skeet, however Jon is definitly not VB.net.
So I think you have more change, when you ask this question as well in the newsgroup
Microsoft.public.dotnet.general as well.
There is Jon often active.
Cor
| | | Reply: by:Daniel Köster
| | | OK! I'll try there as well. Thank you Cor!
|
Posted by Xander Zelders

Convert charref ({) to normal letters
Found the following interesting discussion in the Newsgroups:
Convert charref ({) to normal letters by:Daniel Köster
| Hi I asked this question a couple of days ago as well but I didn't get any answers that I could use.
Is there someone who has got som tips on how to convert text encoded with character referense ({) to unicode or uft-8 format using VB.net? Is there a function or something that can help with the conversion?
To use a simple replace "this" with "that" is not an option since there are som asian-texts that I need to convert as well. (chinese, thai and japanese; the replace list would be to large to handle)
What i want to do is to be able to compare a file coded with character references (i.e. {) with a file coded with normal unicode characters (i.e. ö,ä,å)
Best regards Daniel
| | | Reply: by:Cor Ligthert
| | | Hi Daniel,
These questions like yours in the dotnet newsgroups are mostly answered by Jay B. Harlow, however even more by Jon Skeet, however Jon is definitly not VB.net.
So I think you have more change, when you ask this question as well in the newsgroup
Microsoft.public.dotnet.general as well.
There is Jon often active.
Cor
| | | Reply: by:Daniel Köster
| | | OK! I'll try there as well. Thank you Cor!
|
Posted by Xander Zelders

Using projects
Found the following interesting discussion in the Newsgroups:
using projects by:Anonymous
| Hey Everyone Ok so i've finished a project and now I want to give it to someone else without vb.net, (i want to give it to them as an exe file) How do get the .vb net files to turn into .exe files so I can give it to other people? Thanks everyone.
| | | Reply: by:Lars Netzel
| | | When you Bulid your Project (or solution) they are compiled into an EXE (or dll or other depending on what settings and projecttype you have)
The EXE file by default is place in the BIN folder directly under the root of the projectfolder!
/Lars
| | | Reply: by:Cor Ligthert
| | | Hi Tom,
You can make an msi file using a deployment project,
This link is not the best walkthrough in my opinion however a good start
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vbtskCreatingInstallerForYourApplication.asp
I hope this helps?
Cor
| | | Reply: by:Anonymous
| | | Thanx everyone!
|
Posted by Xander Zelders

Help with Datagrid events please.
Found the following interesting discussion in the Newsgroups:
Help with Datagrid events please. by:Lars Netzel
| I have a datagrid, datasource is a dataset that contains no items... I place the cursor in the first cell in the datagrid and start typing values.. after I have filled in all the "mandatory" fields a new row is created in the bottom of the grid (with a * character as the rowheader).... I need to capture that Event when that happens so I can do other stuff depending on the info I just entered on the first row, but I need to know that that row is okay first.
I tried Datasource Changed but that did'nt give anything!
Besr regards/ Lars Netzel
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
Maybe this will help. http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q823q
Ken
| | | Reply: by:Lars Netzel
| | | Thankx but no, not really, it did'nt help me.
I need to capture a RowChange (or datasource row change) and what I need in that Event is info from the row I came from!
/Lars
| | | Reply: by:Cor Ligthert
| | | Hi Lars,
When that * appears the data is written in the dataset or better in the datatable.
Did you already look if the datatable events can do something for you.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataTableEventsTopic.asp
If you want it before that you will need the datagrid currentcell changes a problem however I thought that did not fire when you acknowledge the row and the * appears.
This is a known problem you often see in this newsgroup, when you go searching for it watch especially for messages/answers from CJ Taylor who often talks about this problem as well, there seems even to be even a difference with this between dotnet 1.0 and dotnet 1.1
I hope this helps anyhow?
Cor
|
Posted by Xander Zelders

Quotes within a text string
Found the following interesting discussion in the Newsgroups:
Quotes within a text string by:Anonymous
| ADVERTISEMENT Is there any way to display quotes Themselves - within a text string
textbox1.text = "This is a "test" of inserting quotes".
I want to actually use quotes within this string around the word test - but the program picks this up as me ending the string and then obviously does not like the work test just sitting there and then it tries ot start up the string again.
Is there a way to insert a special ascii character?
thanks.
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | \\TextBox1.Text = "This is a ""test"" of inserting quotes" ///
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders

Quotes within a text string
Found the following interesting discussion in the Newsgroups:
Quotes within a text string by:Anonymous
| ADVERTISEMENT Is there any way to display quotes Themselves - within a text string
textbox1.text = "This is a "test" of inserting quotes".
I want to actually use quotes within this string around the word test - but the program picks this up as me ending the string and then obviously does not like the work test just sitting there and then it tries ot start up the string again.
Is there a way to insert a special ascii character?
thanks.
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | \\TextBox1.Text = "This is a ""test"" of inserting quotes" ///
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders

Set the default "initial" value of a ComboBox
Found the following interesting discussion in the Newsgroups:
Set the default "initial" value of a ComboBox by:Anonymous
| I have populated (or created a collection) in a ComboBox. However - I would like to set a default value - when my form is first opened (for the ComboBox) - like "Select topic".
However - when I attempt to add this text to the Text property of the Combobox - it does not take. In other words, I type it in the property - but when I leave the field - it is blank. I also tried modifying the ComboBox control - in the following manner:
'ComboBox1 ' Me.ComboBox1.Items.Add("1") Me.ComboBox1.Items.Add("2") Me.ComboBox1.Items.Add("3") Me.ComboBox1.Items.Add("4") Me.ComboBox1.Location = New System.Drawing.Point(56, 38) Me.ComboBox1.Size = New System.Drawing.Size(176, 22) Me.ComboBox1.Text = "Select Topic"
I added the last line "Me.ComboBox1.Text = "Select Topic" - but again - it would not apply the value - when I sent to the emulator.
Why is that?
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | * "=?Utf-8?B?S2VpdGg=?=" <anonymous@discussions.microsoft.com> scripsit: > I have populated (or created a collection) in a ComboBox. However - I would like to set a default value - when my form is first opened (for the ComboBox) - like "Select topic".
Set the control's 'SelectedIndex' property.
-- Herfried K. Wagner [MVP]
| | | Reply: by:George Yefchak
| | | You want "SelectedItem," not "Text."
--George
|
Posted by Xander Zelders

Re: Restrict keys in textbox w/o KeyAscii?
Found the following interesting discussion in the Newsgroups:
Re: Restrict keys in textbox w/o KeyAscii? by:hansolo
| > Ok folks. Had some code in VB6 that worked fine within a TextBox KeyPress
| | | Reply: by:Claes Bergefall
| | | Can't seem to find the start of this thread?! Well, ayway
There is nothing wrong with your keyboard You have your ASCII codes mixed up n = 110 N = 78 Backspace = 8 / = 47
ASCII for Del is irrelevant since it doesn't generate a KeyPress event Never heard of the HELP key. Do you mean F1? You should support ',' aswell (ASCII 44)
/claes
| | | Reply: by:hansolo
| | | Thanks, you are correct as I am sure you know. I was getting my information from the Keys Enumeration member help topic in .NET 2003. Evedently a few things in this table do not match the Ascii codes. Pretty close though.
Thanks for picking up on my error.
Chuck
|
Posted by Xander Zelders

Returning values FROM window form
Found the following interesting discussion in the Newsgroups:
returning values FROM window form by:Graham Blandford
| Hi all,
Quickie - I hope. I already know how to use a forms New() Sub to receive parameters from a calling class - but I don;t know how to return values...
Anyone know the recommended method for doing this?
Thanks, Graham
| | | Reply: by:William Ryan eMVP
| | | Create some properties corresponding to each of those values, or create a class that holds all of them and make a property of that class in your target form.
Before that form closes, set them all...
this.FirstValueYouWantReturned = Whatever; or me.FirstValueYouWantReturned = Whatever (vb.net) and repeat this for each varaible. Assume these properties were added to Form2.
So...
Form2 frm = new Form2(SomeValue, SomeOtherValue);//this means you passed in two variables frm.Show();
or Dim frm as Form2 = new Form2(SomeValue, SomeOtherValue) frm.Show()
now, in form2 set those properties as I showed you above to the values you want returned
string FirstValue = frm.FirstValueYouWantReturned; string SecondValue = frm.SecondValueYouWantReturned;
same process for VB.NET at this point.
Or you coudl just create one property of type someClass that contains all of the variables. Then you set them in the class (remember, it's still a property of Form2 which is essential to either approach, this just consolidates it).
then
string FirstValue = frm.SomeObject.FirstValueYouSet; string SecondValue = frm.SomeObject.SecondValueYouSet;
HTH,
Bill
-- W.G. Ryan MVP Windows - Embedded
http://forums.devbuzz.com http://www.knowdotnet.com/dataaccess.html http://www.msmvps.com/williamryan/
| | | Reply: by:Graham Blandford
| | | Thanks Bill.
I'll give it a try.
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | Add properties to the form and set the property values inside the form.
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders

Make multithreading do only X threads at a time.
Found the following interesting discussion in the Newsgroups:
Make multithreading do only X threads at a time. by:Manuel
| I have a long function that needs to be done 1000 times. I'm multithreading it, but I don't want to load them up all at once, instead load them 10 at a time.
So far the only way I can get it to work is by creating a dummy form with a timer. On the timer function I test if the number of threads are less than 10 then run the remaining ones. This is working fine, but I would like to know how to do it without the form.
This is the code I'm trying to use to accomplish the feat without the form:
Module mdlAny() Public Sub Main() Do FunctionThatCalls10Threads() PauseThisThing() 'Replace this with 'either of the bottom functions Loop End Sub
Private Sub PauseThisThingThatWorks() 'It works with this code: 'On the Timer event, I call 'the FunctionThatChecksTheNumberOfThreads() 'to see if I can close the form. '(and hence continue with the program)
Dim wf As WaitForm = New WaitForm wf.ShowDialog() End Sub
Private Sub PauseThisThingThatDOESNOTWork() 'It doesn't work with this code for waiting
Dim RetValue as Boolean Do System.Threading.Thread.CurrentThread.Sleep(1000) RetValue = FunctionThatChecksTheNumberOfThreads() Loop Until RetValue End Sub End Module
................................................................. Posted via TITANnews - Uncensored Newsgroups Access >>>> at http://www.TitanNews.com <<<< -=Every Newsgroup - Anonymous, UNCENSORED, BROADBAND Downloads=-
| | | Reply: by:Tom Shelton
| | |
' Dummy code, in a fictious Console application Option Strict On Option Explicit On
Imports System Imports System.Threading
Module modMain Private Const MAX_THREADS As Integer = 9 Private threads(MAX_THREADS) As Thread
' just so we can get the system thread handle :) Private Declare Function GetCurrentThreadId Lib "kernel32" () As IntPtr
Public Sub Main() Dim rnd As New Random
For i As Integer = 0 To MAX_THREADS threads(i) = New Thread(AddressOf Run)
' randomize the wait... Thread.Sleep(rnd.Next(100, 1000))
threads(i).Start() Next
Console.ReadLine()
For i As Integer = 0 To MAX_THREADS threads(i).Abort() Next
Console.ReadLine() End Sub
Private Sub Run() Dim i As Integer = 0 Dim id As Integer = GetCurrentThreadId().ToInt32()
Try Do i += 1 Console.WriteLine("ThreadId {0}: i={1}", _ id, i) Thread.Sleep(1000) Loop Catch ex As ThreadAbortException Console.WriteLine("ThreadID {0} Aborted!", id) End Try End Sub End Module
I'm not sure if this is what you wanted... But maybe it will help you :) -- Tom Shelton [MVP]
| | | Reply: by:Manuel
| | | Tom Shelton wrote:
> > I'm not sure if this is what you wanted... But maybe it will help you :)
Not quite. What you are doing is starting the threads every X amount of time, where X is a random number.
I want to be able to run 10 threads and then wait until less than 10 are finished and load 10 more, rinse and repeat...
Thanks
................................................................. Posted via TITANnews - Uncensored Newsgroups Access >>>> at http://www.TitanNews.com <<<< -=Every Newsgroup - Anonymous, UNCENSORED, BROADBAND Downloads=-
| | | Reply: by:Jay B. Harlow [MVP - Outlook]
| | | Manuel, In addition to my other comments.
The reason I suggested a thread pool (either the built in one, or roll your own).
Is that starting & stopping 1000 threads, 10 at a time is expensive. It's generally better to start 10 threads and let each thread process 100 requests. A Thread pool normally has a single queue of requests when a thread is done working on a request it simply gets the next request in order & processes it...
Using the ISynchronizeInvoke interface you could setup the ThreadPool so that it was able to raise an event on your main Thread (your UI thread) to notify it when all the requests were done... (The thread pool object would have an ISynchronizeInvoke variable, when the last request finished it would use ISynchronizeInvoke.Invoke to invoke a delegate, that raised an event. The ISynchronizeInvoke variable would hold an instance of your form, causing ISynchronizeInvoke.Invoke to run on the UI thread. Using ISynchronizeInvoke to raise the event would mean the main form would not need to poll to see if all the requests were done or not...
Hope this helps Jay
| | | Reply: by:Jay B. Harlow [MVP - Outlook]
| | | Manuel, It sounds like you simply want to use the System.Threading.ThreadPool or roll your own Thread Pool.
System.Threading.ThreadPool allows by default 25 threads per processor. To use it you would simply use ThreadPool.QueueUserWorkItem 1000 times with the same function address... See System.Threading.ThreadPool for details...
Alternatively if you want to limit it to 10 threads, you will need to write your own Thread Pool. I would create a new Thread Pool class that started 10 Threads. My Thread Pool class would have a System.Collections.Queue object that represented the requests. Each thread would dequeue an item and work on it. I would have a special request or other mechanism available to tell each thread that it is time to exit. I would also include a single AutoResetEvent, that each thread would wait on to see if an item is in the Queue. Plus there should be a padlock object (I normally use "New Object") that you can SyncLock on to ensure that reading & writing to the queue is properly synchronized.
Writing your own thread pool will not be as easy as I am making it sound, however it is fairly easy! The above should be enough to get you started, alternatively you could search google for a sample. Tom's code may help you get started...
Note I've done the above & posted to the newsgroup my alternative above using a single thread.
Hope this helps Jay
|
Posted by Xander Zelders

Is it possible to execute an iSeries program from a VB.Net application?
Found the following interesting discussion in the Newsgroups:
Is it possible to execute an iSeries program from a VB.Net application? by:Ken Sturgeon
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.2800.1400" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY> <DIV> <P><FONT face=Arial size=2>Is it possible to execute an iSeries program from a VB.Net application? Where might I find some reference material that would get me started?</FONT></P></DIV></BODY></HTML>
| | | Reply: by:AlexS
| | | Hi, Ken
yes, it is possible.
How - depends on what you have to connect to iSeries. I would suggest to go to IBM site and start from products you have available. In simplest form it is possible through FTP connection. Check which commands are available on host and go from there.
HTH Alex
"Ken Sturgeon" <aksturgeon@charter.net> wrote in message news:10bd0pddrfu8v22@corp.supernews.com... Is it possible to execute an iSeries program from a VB.Net application? Where might I find some reference material that would get me started?
| | | Reply: by:Tim Shelton
| | | Do it just like you would a s stored proc in SQL. The only difference instead of putting the program name for the SP you have to use the call command (i.e. call <program name>).
Take a look at IBM's access product. It used to be called Client Access.
Hope this helps.
Tim
|
Posted by Xander Zelders

Datagrid columns
Found the following interesting discussion in the Newsgroups:
datagrid columns by:Lisa
| Still trying to get rich text from my dataset into a datagrid. So far, my strategy has been to derive a custom column style which owns a rich text box:
Public Class RTColumn Inherits DataGridColumnStyle
Dim WithEvents rtb As RichTextBox = New RichTextBox() Dim PHeight As Integer = 0 Dim PSize As Size Dim MHeight As Integer = 0 Dim ioMemoryStream As MemoryStream Dim rtbg As Graphics Dim mfMetaFile As Metafile Dim ptrHDC As IntPtr
I want the rich text box with events, because I'd like to know the size of the contents when the text is assigned to rtb:
Private Sub rtb_ContentsResized(ByVal sender As Object, ByVal e As System.Windows.Forms.ContentsResizedEventArgs) Handles rtb.ContentsResized If e.NewRectangle.Height > MHeight Then MHeight = e.NewRectangle.Height End If If e.NewRectangle.Height > PHeight Then PHeight = e.NewRectangle.Height End If PSize = e.NewRectangle.Size End Sub
To draw the contents of the rtb, I create a metafile in the Paint override: Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal [source] As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing.Brush, ByVal foreBrush As System.Drawing.Brush, ByVal alignToRight As Boolean) Try Dim rt As String = Me.GetColumnValueAtRow([source], rowNum) g.FillRectangle(backBrush, bounds) 'this has the effect of erasing the cell If rt <> "" Then rtb.Rtf = rt ioMemoryStream = New MemoryStream() ' Get a graphics context from the RichTextBox Dim rtbg As Graphics = rtb.CreateGraphics ' Get the device context from the graphics context ptrHDC = rtbg.GetHdc() ' Create a new Enhanced Metafile from the device context mfMetaFile = New Metafile(ioMemoryStream, ptrHDC) ' Release the device context rtbg.ReleaseHdc(ptrHDC) ' Draw the metafile g.DrawImage(mfMetaFile, bounds.X, bounds.Y, PSize.Width, PSize.Height)
End If Catch MsgBox(Err.Description) End Try End Sub 'Paint
Not only does this fail to draw the rich text in the datagrid cell, but I get a 'Cast from type 'DBNull' to type 'String' is not valid' error after scrolling the grid to the last row.
I know about the dotnet.leadit.be/extendeddatagrid. It looks intruiging, but I'd really rather understand what I'm doing, and not have to include another dll with my project. If anyone can point out the error of my ways, I'd very much appreciate it.
| | | Reply: by:Ken Tucker [MVP]
| | | Lisa,
To avoid the cast from dbnull to string error use getcolumnvalueatrow.tostring
Dim rt As String = Me.GetColumnValueAtRow([source], rowNum).tostring
Here is a link on how print a rich text box contents. Maybe the graphics code will help. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/wnf_RichTextBox.asp
Ken
| | | Reply: by:Lisa
| | | Ken, Thanks - the .tostring was a dumb error on my part. And thanks for the reference: I'll look at it tonight.
|
Posted by Xander Zelders

XML?, INI File?, How do I do this?
Found the following interesting discussion in the Newsgroups:
XML?, INI File?, How do I do this? by:Anonymous
| I am writing an app that has a gui with many labels on it. It is launched from within another app with a hotkey. It runs full screen and has an image for a background. The is no border or menu whatsoever. I want the user to be able to change font sizes, label locations, background image and a few other parameters and have the changes reflected when the application is launched. What is the best way to accomplish this?
Thank you, John
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet02122002.asp
Ken
|
Posted by Xander Zelders

character selection in a string
Found the following interesting discussion in the Newsgroups:
character selection in a string by:Anonymous
| I have the following type of data sitting in a varaible:
Just Buttons+button
The text and lenght can change, however, no matter what the length is I would like to strip off the "+" sign and everything to the right of it and place it into another (or the same) variable. What is the easiest way to accomplish this?
Thank you, John
| | | Reply: by:Armin Zingler
| | | Dim s As String
s = "Just Buttons+button"
s = s.Split("+"c)(0) -- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
| | | Reply: by:Jay B. Harlow [MVP - Outlook]
| | | John, In addition to Armin's suggestion:
Dim s As String
s = "Just Buttons+button"
s = s.SubString(0, s.IndexOf("+"c)
I suspect there are probably 2 or 3 other methods you could use ;-)
Hope this helps Jay
| | | Reply: by:Cor Ligthert
| | | HI Jay,
> I suspect there are probably 2 or 3 other methods you could use ;-)
It was for me a challenge and I can give of course a VB left function, however the one you gave is the best in my opinion and therefore I will not bring the OP in problems by giving him another one.
:-)
No need answering.
Cor
|
Posted by Xander Zelders

Split function not working.....
Found the following interesting discussion in the Newsgroups:
Split function not working..... by:Jay
| So I'm writting this software that talks to an IRC server; and occasionaly IRC servers send back data two lines at a time with lines breaks inside. For my own sanity I had been using the split funciton to break these lines down to seperate ones and then process the server commands etc. However lately the split funciton seems incapable of finding chr(10)+chr(13) and wont split the lines. When I dump the data to a text file however and open it in notepad, notepad recognizes the lines and seperates them.
What is going on and how can I fix it?
| | | Reply: by:Sven Groot
| | | A newline in Windows is chr(13) & chr(10) not the other way around.
Use the ControlChars.CrLf or ControlChars.NewLine constants.
-- Sven Groot
http://unforgiven.bloghorn.com
| | | Reply: by:Jay
| | | Oh Thank You, I thought I was going to loose my mind today :-) | A newline in Windows is chr(13) & chr(10) not the other way around. | | Use the ControlChars.CrLf or ControlChars.NewLine constants. | | -- | Sven Groot | | http://unforgiven.bloghorn.com
|
Posted by Xander Zelders

Multi-Lingual application
Found the following interesting discussion in the Newsgroups:
Multi-Lingual application by:Z D
| Hello,
I need to support multiple languages in a product package being developed in both ASP.NET (vb.net) and WinForm .net (c#).
I was wondering if there are any best practice guides, application blocks, resources, tutorials, or just general advice that someone could recommend to get me started.
What is the best way to approach a multi-lingual asp.net application? Same for a WinForms.Net app.
Thank-you very much
-ZD
| | | Reply: by:Patrick Steele [MVP]
| | | See: http://tinyurl.com/2bbcf -- Patrick Steele Microsoft .NET MVP http://weblogs.asp.net/psteele
| | | Reply: by:Cor Ligthert
| | | I am suprissed that I have never seen answers on this kind of questions from by instance EricJ, Dominique, Pieter and other Belgians or Swiss,
For who not know, it are two relative small countries where standard is spoken: Belgie: Dutch, French and for a small part German Swiss: German, French, Italian and a kind of Latin language I thought,
And I am intrested how they deal with this.
Cor
|
Posted by Xander Zelders

HasChanges not being updated?
Found the following interesting discussion in the Newsgroups:
HasChanges not being updated? by:Graham Blandford
| Hi all,
I'm sure I must be missing something here.. I've created a simple parent - child form appl. in which I open a dataset in the parent (MDI) using a dataadaptor to an Access database, and a dataset.
The SELECT of the record set searches for a specific entry, if it returns a 0 rowcount, I go throiugh the motions of adding a row, and opening the child form.. if it is found I just open the child form..
I am passing the dataset through the constuctor to my child form, and if I use a datagrid to change the data, it marks the HasChanges correctly. But, as i am only dealing with one row here, and I would like to use text boxes for each column, I have tried to bind these in code - taken from the ..NET library...DataBindings entry...
The problem is, if I change the data in a text box, (incidentally, if I leave the datagrid on the form, the cell appears to update for the changed text), the HasChanges flag is not being set to True. Is there something I need to code that will cause this to happen?
Here's a snippet of the code...
Parent form:
With daLinkMAN_client_trans
.SelectCommand.Parameters("nman_path").Value = str_nman_path
.Fill(dsLinkMAN)
End With
' if empty then add
If dsLinkMAN.Tables("client_trans").Rows.Count = 0 Then
Dim dr_client_trans As DataRow
dr_client_trans = dsLinkMAN.Tables("client_trans").NewRow
With dr_client_trans
.Item("nman_path") = str_nman_path
.Item("description") = "New database"
.Item("summit_client_id") = ""
dsLinkMAN.Tables("client_trans").Rows.Add(dr_client_trans)
End With
End If
' open client form
Dim frm As New frmClient(daLinkMAN_client_trans, dsLinkMAN, cnLinkMAN)
' frm.MdiParent = Me
frm.ShowDialog()
Debug.WriteLine(dsLinkMAN.HasChanges)
Debug.WriteLine(dsLinkMAN.HasErrors)
daLinkMAN_client_trans.Update(dsLinkMAN.Tables("client_trans"))
dsLinkMAN.Tables("client_trans").Clear()
In the Child form I have...
txtpath.DataBindings.Add(New Binding("Text", ds_client_trans, "client_trans.nman_path"))
txtdescription.DataBindings.Add(New Binding("Text", ds_client_trans, "client_trans.description"))
txtclient.DataBindings.Add(New Binding("Text", ds_client_trans, "client_trans.summit_client_id"))
DataGrid1.DataSource = ds_client_trans.Tables("client_trans") If anyone could shed any light on this I'd be most grateful.
Thanks, Graham
| | | Reply: by:Cor Ligthert
| | |
|
Posted by Xander Zelders

VB6 conversion of UDT to structure - ValueType?
Found the following interesting discussion in the Newsgroups:
VB6 conversion of UDT to structure - ValueType? by:Chuck Ritzke
| Okay, just when I thought I was starting to understand stuff. In VB6...
Type MyDataType Dim Value1 as double Dim Value2 as double End Type
Dim MyData1 as MyDataType Dim MyData2 as MyDataType
MyData1=MyData2
'...Do stuff to MyData2, MyData1
When I did this in VB6, MyData1 and MyData2 were separate values (ie if I changed values on one subsequently, the other remained unchanged). When the code is converted to VB.NET, it changes Type to Structure. I read documentation and it says structures are ValueTypes and not ReferenceTypes like classes. So I expected the same behavior as in VB6. But in my converted code, it appears that MyData1 is just a reference to MyData2 because subsequent changes to one, change the other. What gives? And what is the easiest way to create a cloned MyData1 instead of just a reference to MyData2? I hope I don't have to go thru my VB6 code and set each value inside the structure.
TIA, Chuck
| | | Reply: by:Patrick Steele [MVP]
| | | There must be something else wrong in your code. I was unable to produce such behavior using this code:
Option Strict On Option Explicit On
Structure MyDataType Dim val1 As Double Dim val2 As Double End Structure
Module Module1
Sub Main() Dim d1 As MyDataType Dim d2 As MyDataType
d1.val1 = 11 d1.val2 = 22
d2 = d1
d1.val1 = 999 d1.val2 = 888 End Sub
End Module
-- Patrick Steele Microsoft .NET MVP http://weblogs.asp.net/psteele
| | | Reply: by:Chuck Ritzke
| | | Thanks Patrick,
I looked further and realized that my problem happens because the value inside the structure are arrays. Arrays inside the structure become references to each other whereas primitive variables stay independent. It sure would help to have a quick fix to handle this difference between VB6 and .NET.
So modifying your example...
Structure MyDataType Dim val1() As Double Dim val2 As Double End Structure
Module Module1
Sub Main() Dim d1 As MyDataType Dim d2 As MyDataType reDim d1.val1(1) reDim d2.val1(1)
d1.val1(1) = 11 d2.val1(1) = 22 d1.val2=44 d2.val2=55 'AT THIS POINT BOTH ARRAYS AND VARIABLES INSIDE d1 and d2 ARE INDEPENDENT
d2=d1
d2.val1(1) = 999 d2.val2=888 'NOW THE RESULT IS 'd1.val(1)=999 and d2.val(1)=999 and now reference each other whereas... 'd1.val2=55 and d2.val2=88 are still independent
End Sub
End Module
| | | Reply: by:Chuck Ritzke
| | | It looks like I can write a "cloning" function for each UDT to handle arrays...
Function CloneMyDataType(MyData as MyDataType)
Dim MyCopy as MyDataType
MyCopy=MyData MyCopy.Val1=VB6.CopyArray(MyData.Val1) 'and repeat last line for each array in MyDataType
Return MyCopy
End Function
'Then instead of d2=d1
d2=CloneMyDataType(d1) But do you have a quicker/better way? I have lots of UDT's each with lots of arrays inside.
TIA, Chuck
| | | Reply: by:Patrick Steele [MVP]
| | | In .NET you could implement the ICloneable interface and get basically the same results.
But, in the end, you will have to copy the arrays manually when copying the structs (types). This is known as a "deep copy". By default, you get a "shallow copy" where only the reference to the array is copied -- thus making both structs point to a single array.
-- Patrick Steele Microsoft .NET MVP http://weblogs.asp.net/psteele
|
Posted by Xander Zelders

Deployment question
Found the following interesting discussion in the Newsgroups:
Deployment question by:Woody Splawn
| I have a non-web VB.net applicaiton that I have written. I have written it on a client machine of a local area network. The solution is on the local hard drive of this client machine with the back-end database (SQL Server) on the file server of the network. How do I now make this applicaiton availab |
| |