|
I find that an interesting statement. Why would you consider using a global variable "bad code" as opposed to using a delegate?
|
|
|
|
|
Because it's a quick and dirty fix that breaks encapsulation. I know in VB6 such things were common, but in OO programming, it's not how things are done.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i haven't got any problems with such type of coding. i know what delegates are, i didn't replied, instructing him to use it, because i didn't remembered it.that way was the first one that came to my mind
|
|
|
|
|
I am relatively new to the .net frmework, but i LOVE IT. I was die-hard to upgrade from vb6, but I am glad I did.
Here is my problem. I am useing visual studio (vb.net) 2005. In my app, I use an API call to retireive a list of file object handles from a portable media device useing the Media Transport Protocol. ( I know what the handles of the files actually are becuase I use the direct MTP tool to show me what they are.) Here is API call I use:
Sub GetObjectHandles(ByVal StorageId As UInteger, ByVal FormatCode As MtpLib.MTP_FORMATCODE, ByVal ParentObjectHandle As UInteger, ByRef pcelt As Integer, _
ByVal ppObjectHandles As System.IntPtr, ByRef pResponseCode As MtpLib.MTP_RESPONSECODE)
And here is how i use it:
<code>
'Namespace
Imports MtpLib
Imports System.Runtime.InteropServices ' I added for marshaling
Public MTP AsNew MtpLib.WindowsMtp
'Decalres
Dim pCelt As Integer 'To hold the count of object found
Dim objHandles as IntPtr 'To hold the object handle? or the Ptr to the object handle?
Dim resCode as MtpLib.MTP_RESPONSECODE 'Response from API
'In my sub I use :
MTP.GetObjectHandles(65537, 0, 0, pcelt, objHandles, resCode)</code>
When I run the code I get this error :
"AccessViolationException was unhandled" - "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
I figured this was because the IntPtr variable needed to be marshaled. Problem is HOW? I don't know alot about marshaling. Can some please try and describe some working code for me? I have completed the entire program by designing around static object handles. It would really be nice to get all the files at runtime you know?
Also,
I know the storage id is correct (because I used it successfully in other API calls in the app)
AND
I know the procedure is returning the correct amount of files, because pCelt is equall to 312 after the procedure fails (and there are exactly 312 files on my device) problem is, I think the objHand is an array of file handles and I need to convert them. When I tried my hand at marshaling them, I got random numbers every time (or what seemed like random numbers.)
I have been working on this same problem nowfor two weeks I feel like I could just cry. This API seems so straight forward. Do I need to create a structure and then read / write it ? if so how.
Any help would be greatly appreciated.
|
|
|
|
|
Where did this "MtpLib" come from? Whoever wrote it is going to be your best source of information.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
The MTPLib.dll is from Microsoft's Media Tranport Protocol Kit SDK.
|
|
|
|
|
VB.Net - I am trying to create a list of currently running threads and iterate through them to abort a thread with a certain name. Like so:
'list() = list of currently running threads
'''for each thread in list
''''''if thread.name = whatever
'''''''''thread.abort
''''''endif
'''next
thanks in advance for any assistance.
John
|
|
|
|
|
That will work, so long as you add your thread objects to the array when you create them.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks alot, it is up and running.
John
|
|
|
|
|
Doubtful, I'd say you should go and look in a 2nd hand bookstore for old VB6 books. MS doesn't support VB6 anymore ( for quite a while ), so no help there. www.vbcity.com is an option.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi I am tring to read a xml in vs2005
my code keeps raising the following exception: "illegal characters in path"
here is the vb.net code:
Dim ds As New DataSet
ds.ReadXml(xmlout)
ds.WriteXml("C:\Query.xml")
here is the xml doc i am reading:
<?xml version="1.0" encoding="Windows-1252"?>
<InvQuery Language='05' CssStyle='' DecFormat='1' DateFormat='01' Role='01' Version='6.0.015'>
<StockItem>
<StockCode>R00001</StockCode>
<Description>POLYCARBONATE</Description>
<LongDesc>POLYCARBONATE RAW</LongDesc>
<AlternateKey1/>
<AlternateKey2/>
<Version/>
<Release/>
<StockUom>KG</StockUom>
<AlternateUom>GM</AlternateUom>
<ConvFactAltUom> 1000.000000</ConvFactAltUom>
<ConvMulDiv>D</ConvMulDiv>
<OtherUom>KG</OtherUom>
<ConvFactOthUom> 1.000000</ConvFactOthUom>
<MulDiv>M</MulDiv>
<StockAndAltUm>N</StockAndAltUm>
<PartCategory>B</PartCategory>
<Supplier/>
<ProductClass>POLY</ProductClass>
<Buyer/>
<Planner/>
<TraceableType>N</TraceableType>
<MpsFlag>N</MpsFlag>
<SupercessionDate/>
<DrawOfficeNum/>
<Ebq> 1.000</Ebq>
<DockToStock> 0</DockToStock>
<ManufLeadTime> 0</ManufLeadTime>
<TariffCode/>
<UserField1/>
<UserField2> 0.00000</UserField2>
<UserField3/>
<UserField4/>
<UserField5/>
<LeadTime> 5</LeadTime>
<WarehouseToUse>B2</WarehouseToUse>
<GrossReqRule>I</GrossReqRule>
<EccUser/>
<Mass> 0.000000</Mass>
<Volume> 0.000000</Volume>
<PriceCategory>A</PriceCategory>
<PriceMethod>C</PriceMethod>
<CycleCount> 0</CycleCount>
<TaxCode>B</TaxCode>
<OtherTaxCode/>
<ListPriceCode/>
<SerialMethod>N</SerialMethod>
<KitType>N</KitType>
<BulkIssueFlag>N</BulkIssueFlag>
<AbcClass/>
<StockMovementReq>Y</StockMovementReq>
<ClearingFlag>N</ClearingFlag>
<AbcAnalysisReq>Y</AbcAnalysisReq>
<AbcCostingReq/>
<CostUom>KG</CostUom>
<StockOnHold/>
<StockOnHoldReason/>
</StockItem>
<WarehouseItem>
<Warehouse>B2</Warehouse>
<Description>BRAESIDE RAW MATERIALS</Description>
<QtyOnHand> 14320.580</QtyOnHand>
<AvailableQty> 14320.580</AvailableQty>
<QtyOnOrder> 333500.000</QtyOnOrder>
<QtyInInspection> 0.000</QtyInInspection>
<MinimumQty> 0.000</MinimumQty>
<MaximumQty> 0.000</MaximumQty>
<QtyOnBackOrder> 0.000</QtyOnBackOrder>
<QtyAllocated> 0.000</QtyAllocated>
<MtdQtyReceived> 15000.000</MtdQtyReceived>
<MtdQtyAdjusted> -4418.896</MtdQtyAdjusted>
<MtdQtyIssued> 19229.420</MtdQtyIssued>
<YtdQtySold> 0.000</YtdQtySold>
<PrevYearQtySold> 209807.530</PrevYearQtySold>
<QtyInTransit> 0.000</QtyInTransit>
<QtyAllocatedWip> 83114.600</QtyAllocatedWip>
<MtdQtySold Height='000' Top=' 25535'> 0.000</MtdQtySold>
<MtdQtyTrf> 0.000</MtdQtyTrf>
<UserField1/>
<UserField2/>
<UserField3/>
<DefaultBin/>
<UnitCost> 4.96228</UnitCost>
<SalesQtyByMonth>
<SalesQty1 Height='061'> 15575.800</SalesQty1>
<SalesQty2 Height='062'> 15755.304</SalesQty2>
<SalesQty3 Height='065'> 16712.316</SalesQty3>
<SalesQty4 Height='063'> 16025.252</SalesQty4>
<SalesQty5 Height='061'> 15491.400</SalesQty5>
<SalesQty6 Height='072'> 18400.806</SalesQty6>
<SalesQty7 Height='067'> 17022.060</SalesQty7>
<SalesQty8 Height='044'> 11324.508</SalesQty8>
<SalesQty9 Height='052'> 13304.464</SalesQty9>
<SalesQty10 Height='100'> 25535.280</SalesQty10>
<SalesQty11 Height='095'> 24366.672</SalesQty11>
<SalesQty12 Height='091'> 23143.720</SalesQty12>
</SalesQtyByMonth>
</WarehouseItem>
<WarehouseItem>
<Warehouse>N2</Warehouse>
<Description>NORTHMEAD RAW MATERIALS</Description>
<QtyOnHand> 36998.000</QtyOnHand>
<AvailableQty> 36998.000</AvailableQty>
<QtyOnOrder> 148500.000</QtyOnOrder>
<QtyInInspection> 0.000</QtyInInspection>
<MinimumQty> 0.000</MinimumQty>
<MaximumQty> 0.000</MaximumQty>
<QtyOnBackOrder> 0.000</QtyOnBackOrder>
<QtyAllocated> 0.000</QtyAllocated>
<MtdQtyReceived> 35500.000</MtdQtyReceived>
<MtdQtyAdjusted> 825.408</MtdQtyAdjusted>
<MtdQtyIssued> 52752.000</MtdQtyIssued>
<YtdQtySold> 0.000</YtdQtySold>
<PrevYearQtySold> 406309.904</PrevYearQtySold>
<QtyInTransit> 0.000</QtyInTransit>
<QtyAllocatedWip> -46109.144</QtyAllocatedWip>
<MtdQtySold Height='000' Top=' 55367'> 0.000</MtdQtySold>
<MtdQtyTrf> 0.000</MtdQtyTrf>
<UserField1/>
<UserField2/>
<UserField3/>
<DefaultBin/>
<UnitCost> 5.01040</UnitCost>
<SalesQtyByMonth>
<SalesQty1 Height='074'> 41175.410</SalesQty1>
<SalesQty2 Height='100'> 55367.712</SalesQty2>
<SalesQty3 Height='055'> 30331.044</SalesQty3>
<SalesQty4 Height='058'> 32120.580</SalesQty4>
<SalesQty5 Height='044'> 24530.728</SalesQty5>
<SalesQty6 Height='067'> 37250.100</SalesQty6>
<SalesQty7 Height='063'> 34816.440</SalesQty7>
<SalesQty8 Height='063'> 35081.756</SalesQty8>
<SalesQty9 Height='058'> 32207.516</SalesQty9>
<SalesQty10 Height='073'> 40260.420</SalesQty10>
<SalesQty11 Height='065'> 36142.216</SalesQty11>
<SalesQty12 Height='064'> 35711.832</SalesQty12>
</SalesQtyByMonth>
</WarehouseItem>
</InvQuery>
Any help would be appreciated
Cheers
|
|
|
|
|
thedom2 wrote: ds.WriteXml("C:\Query.xml")
How does VB handle \, do you need to do \\, as in "c:\\query.xml" ? You do in C#.
thedom2 wrote: xmlout
I guess you need to step through the code, see what's in this variable, and see if this or the next line is blowing up.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: How does VB handle \, do you need to do \\, as in "c:\\query.xml" ? You do in C#.
Not true for VB. Single "\" work just fine. Doubles are required in C\C++\C# unless the string escaped by some literal character, @"" or L"" or whatever...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I make a project by VB with Crestal Report
it is good and working good but when i change the project place to another it works but the reports give false values it seams to be there is a link between the crystal and the database so I must chang the link when I change the project place after I doing that the project after changing its place works by good reports
the question :
is there any way (code way) to change the link between crystal and database without opening evry report and instead of change it manually?????????????
soly
|
|
|
|
|
I don't know if I understand your question, but I believe you are saying this: You have a crystal report at location X and it's set to work with a database at location X. Then you make a copy/move your crystal report to location Y and it doesn't work because it is still pointing to the database at location X (not the copy/moved version at location Y). And each time you move/copy things you have to open the crystal report and edit it to point to the new location.
Unfortunately I don't know how to work around this. I mean, in code you can set a crystal report's datasource to a datatable object (which you can program to get from any database at any location) like this:
reportDocument1.SetDataSource(dtMyDataTable)
as long as the datatable parameter matches what you used to design the crystal report this works.
...but if you are talking about moving whole projects I don't know how to help you. Sorry.
|
|
|
|
|
I was told that I can text to cell phones from my pc or at this web sight....but can't get an answer..can someone help my retarded ass??
|
|
|
|
|
Do you mean in a program, or are you asking a general, consumer level question in a programming forum ?
There used to be web sites that would send SMS, I dunno if there still are.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I have a datagrid whose datasource is a dataset.
<br />
Dim DiagCmd As DbCommand = db.GetStoredProcCommand("p_Get_All_Diags")<br />
Dim dsDiags As DataSet = New DataSet("Diagnostic_Codes")<br />
dsDiags = db.ExecuteDataSet(DiagCmd)<br />
dgDiags.DataSource = dsDiags.Tables(0).DefaultView<br />
The above works.....
Now, I want to be able to click a button and move an item from one grid to another... sounds simple enough.... The code to do that is below....
<br />
Private Sub btnNxt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNxt.Click<br />
<br />
dsAuto.Tables(0).Rows.Add(dsDiags.Tables(0).Rows(dgDiags.RowSel - 1).ItemArray)<br />
<br />
End Sub<br />
and this works.... my problem is if I click on the columnheader and change the sort order it will move the item based on how they originally appeared in the grid.
ie. if the grid starts with A-Z and I click the header making it Z-A.... if I then click Z(Which is now at the top) and click my btnNxt it will move A.
Anybody help is greatly appreciated...
-Kay
|
|
|
|
|
Hi, does anyone know how to code the 'memory' buttons on a calculator
(memory =, - , Clear, and Recall) in VB.
Thanks a bunch.
|
|
|
|
|
That smells like homework to me. Google 'variables VB.NET'.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I would like to create a dataset that indicates whether co-ordinates on a grid are occupied. How do I set the composite primary key to be made up of xPosition and yPosition?
Then I need to populate the values with 'false' initially and mark them as true through a function. How do I populate the values?
Is the size of the dataset incremented automatically as I increment the values or do I have to do it explicitly?
Public Class Plateau
...
Private Sub initDataSource()
'Create PlateauPostions
'define attributes
With plateauPositions
.Columns.Add("xPosition", System.Type.GetType("system.int32"))
.Columns.Add("yPosition", System.Type.GetType("system.int32"))
.Columns.Add("occupied", System.Type.GetType("System.boolean"))
End With
'enforce composite primary key on xPosition and yPosition
... ??
End Sub
Jon
|
|
|
|
|
I have a problem using the picturebox. i am creating a game and i am using my character as a picturebox. i am moving him using the (w - a - s - d) format. now .. when i am pressing the "D" .. the code is doing this:
picSnake.Location = new point(picsnake.location.x + 4, picsnake.location.y).
Now the problem is this: the snake is moving to the right as it is suppose. but the problem is this that the picture is refreshing itself and when i am pressing the "D" and keep the "D" pressed all the time, the picture is like erasing itself and then it comes back again and goes to the right because the "D" is pressed. how can i solve this problem?? its very ugly right now
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
You can't do this with a picturebox and expect it to work nicely. You should draw the image direct to screen, or, unless the game is simple, look in to DirectX.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
can i use directx using vb.net??
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
Of course - just download the SDK and it should install managed DX automatically.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|