|
I'm working on a form editor a.k.a like in Visual Studio and sharpdevelop. I save the forms out as xml mainly using to the .ToString methods and then try to convert them back on load.
I thought this would be the way to do it:-
Dim PInfo As PropertyInfo = ty.GetProperty(Nde.Name)<br />
If Not PInfo Is Nothing Then<br />
Dim t As Type = PInfo.GetType()<br />
PInfo.SetValue(ctrl, (CType(Nde.Value, PInfo.GetType())), Nothing)<br />
End If
but CType and DirectCast do not accept PInfo.GetType() . They demand a hand coded type e.g. CType(Value, Integer) . Does anybody know of a way to do this?
I look for the TagName via reflection :- Dim PInfo As PropertyInfo = ty.GetProperty(Nde.Name) and it returns fine, so it's found the property. But how do I then convert the value to the correct Type so I can set the property value?
Demo XML:
<code><VISIBLE>True</VISIBLE>
<Text>Caption :</Text>
<TextAlign>1</TextAlign></code>
|
|
|
|
|
can any one send me code/url for DES Encrypyion/Decryption in VB6.0
|
|
|
|
|
Is there a simple way to print the contents of a datagrid in VB.NET? Thanks for any help.
|
|
|
|
|
Does anyone know how to remove the items under the 'Recent' tab when opening a previous project? Right now I have like 50 projects under there and a lot of it is clutter.
Thanks.
|
|
|
|
|
Ok this is something
The problem I have is that when I'm calculating some values the sum is rounded and i dont want it
for example, here is some of my code
******************** code *******************
dim price, totalprice, tax as Long
Format TotalPrice, "$#,##0;;\Z\e\r\o"
Format Tax, "$#,##0;;\Z\e\r\o"
Format Price, "$#,##0;;\Z\e\r\o"
Price = 0
For i = 0 To 21
Price = Price + LBLSelPrice(i).Caption
Next
LblTotal.Caption = Price ' eg 125
Tax = (Price * 0.18)
LblTax.Caption = Tax 'equals 22.5, displays fine
TotalPrice = Tax + Price
LblGenTotal = TotalPrice ' Here it displays 148 instead of 147.50
*********************** code ******************
while debugging I noticed that the problem is not the labels problem but I was watching my variables and
I saw that the totalprice var. when I am summarizing the price and the tax vars is rounded. In the labels properties
I changed the format to number with 2 decimal points !!!
It s not workink, no way !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
HELP !!!
Mike Eco
|
|
|
|
|
Variables declared as Long cannot hold fractional parts, and will always be rounded.
Dim Price As Currency, TotalPrice As Currency, Tax as Currency, i As Long
Price = 0
For i = 0 To 21
Price = Price + CCur(LBLSelPrice(i).Caption)
Next
LblTotal.Caption = Price
Tax = (Price * 0.18)
LblTax.Caption = Tax
TotalPrice = Tax + Price
LblGenTotal.Caption = TotalPrice
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
I want to pass an Enum to a function like this:
Private Enum AnyEnum
a
b
End Enum
Public Sub Any(ByVal Enumeration As [Enum])
...
...
End Sub
..
..
Call Any(AnyEnum)
..
How can this be done?
Regards
Hardy
|
|
|
|
|
Firstly, you aren't able to expose a private member as a parameter of a public method.
Here's some working code:
Module Module1
Public Enum AnyEnum
a
b
End Enum
Public Sub Any(ByVal Enumeration As AnyEnum)
End Sub
Sub Main()
Any(AnyEnum.a)
End Sub
End Module Does this help you?
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
animation mechanics in SVG
|
|
|
|
|
Thank's a lot for your quick response,Simon.
I don't want to pass an enumerated value, but the enumeration itself, like this:
Module Module1
Public Enum AnyEnum
a
b
End Enum
Public Sub Any(ByVal Enumeration As [Enum])
End Sub
Sub Main()
Any(??AnyEnum??)
End Sub
End Module
Kind regards
Hardy
|
|
|
|
|
Try this:
Module Module1
Public Enum AnyEnum
a = 0
b = 1
End Enum
Public Sub Any(ByVal Enumeration As [Enum])
Dim myenum As AnyEnum = CType(Enumeration, AnyEnum)
Console.WriteLine(myenum.b)
End Sub
Sub Main()
Console.WriteLine("before")
Any(New AnyEnum())
Console.WriteLine("after")
Console.ReadLine()
End Sub
End Module
Hardy, I'm really interested to know ... why?
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
animation mechanics in SVG
|
|
|
|
|
Hi,
I'm having a strange problem trying to postmessage out of VB.NET.
I have PostMessage defined as
Public Declare Function PostMessage _
Lib "user32" _
Alias "PostMessageA" _
(ByVal hwnd As IntPtr, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
The wMsg is arriving perfectly at hwnd, but wParam is always 0 and even stranger is lParam is always equal to the value that should be in wParam
The wParam is defined as a long and has the value 10 when posting, lParam is defiend as Long and has the value Me.Handle.ToInt64()
When the message arrives, though wParam = 0 and lParam = 10
Any ideas? This is driving me mad!
Many thanks in advance
Mark
|
|
|
|
|
In VB6, Long was a 32-bit integer. In VB.NET, Long is a 64-bit integer, and Integer is the 32-bit integer. Unless you're working on a 64-bit version of Windows, you need to use 32-bit integers:
Public Declare Function PostMessage _
Lib "user32" _
Alias "PostMessageA" _
(ByVal hwnd As IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Integer
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hello all,
Is there a way in VB 6.0 to make the system wait for a bit.
Like system.wait(1000) where it will wait 1000 ms or something? I suppose I could write a for loop for 1 to SomeBigNumber and every 1000 do what I want to do, but this seems like a silly way to do things.
Let me know please if there is a wait command.
Thanks!!
Oh yeah one other quick question. When I run my VB program, the Focus doesn't automatically start on the command button, like I would like. I went to the form load area and wrote
cmd_calc.SetFocus (hoping that this would set focus to my command button)
It gives me an error sayign invalid procedure call or argument. How can I get the focus to start on my command button?
Again thank you very much!
NickOne
|
|
|
|
|
NickOne wrote:
Is there a way in VB 6.0 to make the system wait for a bit.
Look in the SDK for the Sleep Win32 API call
Look here for an example:
http://www.buygold.net/v02n11/v02n11.html[^]
NickOne wrote:
It gives me an error sayign invalid procedure call or argument. How can I get the focus to start on my command button?
Place the setfocus call in the formActivate event. The form load event fires as the form is being built and the control might not be available at that point yet.
It will also help if you have all the controls Tab orders and indexes set properly.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
Hi, I 'm new to programming and I 'm having this problem with visual basic.
I have a DB combo which has a datasource. The datasource is an array eg. data(0)
I have set the rowsource and listfield property to fill up my combo.
When I 'm trying to change the recordsource of my data control writing for example
data(0).recordsource = "Select * From Products where Productname = CPU"
and then trying to refresh my datasource
data(0).refresh
i got the following error
Run-time error '3061':
Too few parameters. Expected 1.
Can somebody help me please ???
Best Regards
Mike Economou
|
|
|
|
|
;PI declare my procedure like:
Private Sub childTreeViewProject_DoubleClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles childTreeViewProject.DoubleClick
It doesn't work,
saying methods haven't the same signatures.
|
|
|
|
|
The event is Control.DoubleClick and is an EventHandler, meaning that the second parameter is an EventArgs.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
i have successfully generated a report based on grouping. However, when i try to generate a report based on subgroups, i get returned with this error: "report sections do not match data source". why is this? here is my code in the form:
Load deTypeCustomerReport
With deTypeCustomerReport
.TypeCustomerReport_Grouping CDate(Text1.Text)
End With
rptTypeCustomerReport.Refresh
If rptTypeCustomerReport.Visible = False Then
rptTypeCustomerReport.Show
End If
i have placed 1 field (company) in one of the group headers, the other (ProductType) in a second group header and the remainder of the fields in the detail section.
any help would be greatly appreciated!
|
|
|
|
|
hello,
I am trying to learn how to call a subroutine at the beginning of a program, before anyone has to click on anything. I am writing a real simple unit conversion program, and I wanted to display this menu inside a picture box:
pic_unitDisplay.Print "1. inch", "2. fathom", "3. foot"
pic_unitDisplay.Print "4. furlong", "5. kilometer", "6. meter"
pic_unitDisplay.Print "7. fathom", "8. rod", "9. yard"
(oh yeah I am doingthis in VB 6)
So I placed that in a subroutine called unitDisplay. If I call subroutine on any of the click, like a command button or anything, it'll pop up like I want. BUT I want it to pop up first, right at the beginning of the program. How do I call a subroutine right at the beginning of program execution?
Thanks
Nick
|
|
|
|
|
hi..
write your code in the Form_Load() event..
make sure that AutoRedraw property of the picture control is set to true
|
|
|
|
|
add a Sub Main module. then change your project preferences
sub Main
frmConevert.show vbModal,me
end sub
----
sub Form_Load
' setup
pic_unitDisplay.Print "1. inch", "2. fathom", "3. foot"
pic_unitDisplay.Print "4. furlong", "5. kilometer", "6. meter"
pic_unitDisplay.Print "7. fathom", "8. rod", "9. yard"
end sub
|
|
|
|
|
I am trying to generate a report in VB. What the report is generating is the individual product turnover in a given period (ie between 2 date values,obtained from 2textboxes), and grouped by product type. To do this, i have created a data environment, set up a connection and added a command. using the SQL builder, i have tried to create a SQL statement to satisfy the data i am trying to articulate. all the examples i have seen accept parametres in the select clause but not the Where so i dont know the syntax for what i am trying to achieve. here is the SQL:
SELECT Product.Description, COUNT(OrderDetail.Quantity) AS Quantity, SUM(OrderDetail.Price) AS Price, ProductType.Description AS TypeDescription FROM Product, ProductType, OrderGenerate, OrderDetail WHERE Product .TypeCode = ProductType.TypeCode AND (OrderGenerate.OrderDate) BETWEEN = ? AND = ?
and my code under the command button to generate the report is:
deProductTurnover.ProductTurnover_Grouping dStart, dFinish
rptProductTurnover.Show
i have defined the parametres and the appropriate groups aswell.
what am i doing wrong, what is the correct SQL statement? the error being returned is: "unabled to determine the parameter information for the parameters. Use the parameters Tab to specify appropriate info". any help would be greatly appreciated!
|
|
|
|
|
Hi all,
I've created a data carrier class, with some basic public properties. I've also created a strong typed collection for that class like this:
<Serializable()> _
Public Class CustomerCollection
Inherits CollectionBase
Public Default Property Item(index As Integer) As Customer
Return MyBase.InnerList.Item(index)
End Property
'Functionality to fill collection with customers...
End Class
This CustomerCollection-class is exposed by a webservice, like this:
<WebMethod()> Public Function GetCustomers() As CustomerCollection
Dim customers As New CustomerCollection
Customers.Fill
Return customers
End Function
The webservice works fine, I can reference it in another project and consume the data. But when I try to bind the returned array of Customers to a DataGrid, the DataGrid does not show the columns...
Dim ws As New localhost.CustomerEngine
DataGrid1.DataSource = ws.GetCustomers
I can see how many rows/items the collection/array has, but there is not a single column that shows a property of the Customer class.
I've searched for a solution for this problem, but I haven't found one. So I hope someone can help me with this one.
Thanx,
Jan
|
|
|
|
|
Hi all
I've created a solution for this problem, for who is intrested, you can find it here: http://www.codeproject.com/useritems/LeaditWebServiceWrapper.asp.
Jan
|
|
|
|
|
I am a C++ programmer just starting work on a VB program (for the first time), and could find a string format similar to printf or CString::Format(). Does VB 6.0 (not VB.NET) support this? If not, is the only other way concatenating strings? For example (VC++ CString::Format()):
strTemp.Format( "Visual Basic %d", 6 );
This is a simple example, but if I had a lengthy SQL statement, this would be handy...
Thanks in advance!
Derek
|
|
|
|
|