|
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
|
|
|
|
|
I'm beginner in VB too..
that's what I found in MFC. Hope it is useful.
<br />
Dim MyTime, MyDate, MyStr<br />
MyTime = #17:04:23#<br />
MyDate = #January 27, 1993#<br />
<br />
' Returns current system time in the system-defined long time format.<br />
MyStr = Format(Time, "Long Time")<br />
<br />
' Returns current system date in the system-defined long date format.<br />
MyStr = Format(Date, "Long Date")<br />
<br />
MyStr = Format(MyTime, "h:m:s") ' Returns "17:4:23".<br />
MyStr = Format(MyTime, "hh:mm:ss AMPM") ' Returns "05:04:23 PM".<br />
MyStr = Format(MyDate, "dddd, mmm d yyyy") ' Returns "Wednesday,<br />
' Jan 27 1993".<br />
' If format is not supplied, a string is returned.<br />
MyStr = Format(23) ' Returns "23".<br />
<br />
' User-defined formats.<br />
MyStr = Format(5459.4, "##,##0.00") ' Returns "5,459.40".<br />
MyStr = Format(334.9, "###0.00") ' Returns "334.90".<br />
MyStr = Format(5, "0.00%") ' Returns "500.00%".<br />
MyStr = Format("HELLO", "<") ' Returns "hello".<br />
MyStr = Format("This is it", ">") ' Returns "THIS IS IT".<br />
<br />
|
|
|
|
|
Thanks - unfortunately I was looking for something like:
' Note: Contrived example...<br />
Dim fmt As String<br />
Dim sql As String<br />
<br />
'Imaginary Format Function<br />
fmt = "SELECT FirstName from Employee WHERE Zip=%d and AreaCode=%d"<br />
sql = Format(fmt, 04401, 207)
Does this imaginary function exist natively in VB 6.0 somewhere?
|
|
|
|
|
I work c++ and vb to and i can tell you that those languages have nothing common.
For example with the "printf" function you display something on the screen
In vb you need to crate a label or text for example and the assign the value you want to your object.
eg.
'Declare your variables
Dim fmt As String
Dim sql As String
Dim InputStr As String
' %d is an input from the user right? So here you have to do this using a text box.
'when the user types the value he wants in the text box you get it and work with it
' eg
Let say user gives the value "18542" for are code in the text box
InputStr = text1.text
' Now the InputStr Variable has the value "18542"
fmt = "Select Firstname from Employee where zip = " & InputStr
' This means that the statement is Select Firstname from Employee where zip = 18542
' Those results don't expect to get them anywhere in the screen
' Create a Label or text (label for example and connect it to your data control
'Refresh your data control after assigning your new SQL Statement and you will get the result in your label
I hope this will help you
Mike Economou
|
|
|
|
|
Hi!
I would like to know how can i, pressing the form's minimize button, run a function of mine that makes the aplication to run in the system tray, this last part is done, i just can't find anything that allows me to catch the minimize button event.
Can anyone help me?
Thank you for your time
|
|
|
|
|
Try this:
Private Sub Test(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
MsgBox("Worked")
End If
End Sub
Let me know if this helps.
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
|
|
|
|
|
Try this:
Private Sub Form1_Deactivate(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Deactivate
If Me.WindowState = FormWindowState.Minimized Then
Me.Hide()
End If
End Sub
Or if you already have a function of your own then simply replace the Me.Hide() part and you are in business.
Good Luck
|
|
|
|
|
Hi all!
how can I convert the number ( 42 ) to A
I mean in ASCII code 42 is an "A" so If I have number 42 how can I convert it into "A" in VB.
I know that in C++ I can used IsAlpha().
Thanks
|
|
|
|
|
Hi Win
Here's the VB.NET code (hope this is the VB ver. you wanted):
Imports System.Text.Encoding
Imports Microsoft.VisualBasic
Module Module1
Sub Main()
Dim i As Integer = AscW("A")
Console.WriteLine(i.ToString())
Dim c As Char = ChrW(i)
Console.WriteLine(c.ToString())
Console.ReadLine()
End Sub
End Module
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
|
|
|
|
|
Thanks Simon. That's exactly what I want.
Thanks millions....
|
|
|
|
|
Cool, glad it helped.
The wierd thing is that MS/other seem to recommend not using the Microsoft.VisualBasic namespace as (I think) it uses interop in the background.
Perhaps keep this code in a single function so it won't be too much of a sweat to change later, if necessary.
I'll keep a look out for an alternative.
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
|
|
|
|
|
Hmmm.....isn't easier to use the Chr function??
Chr(65) = "A"
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Would have been the way I would go.
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."
|
|
|
|
|
|
i had generated a report from a query in access (ie using the query as a datasource), and that worked fine. However, now i want to run the report based on the query in the database and 2 values (ie between 2 dates) in textboxes so i have hardcoded the following SQL statement behind the command button to generate the report. However, i do not know what to do from here - the SQL statement will be a datasource and datamember for what - the data environment? the command? the report? Thanking you!
SELECT DISTINCT Client.Company, OrderGenerate.OrderNumber, Sum(OrderDetail.Price) AS SumOfPrice
FROM (Client INNER JOIN OrderGenerate ON Client.ClientCode=OrderGenerate.ClientCode) INNER JOIN OrderDetail ON OrderGenerate.OrderNumber=OrderDetail.OrderNo
WHERE Date Between ' " & txtDateFrom.Text & "' and ' " & txtDateTo.Text & "'
GROUP BY Client.Company, OrderGenerate.OrderNumber
|
|
|
|
|
Hi,
I found the following code in the MSDN Articles. The title of the article is "Customizing Microsoft Internet Explorer 5.0". I don't know why it isn't working. It asks if I want to create the button but then it does nothing. Could you help me please?
Thank you
' AddButtonIE.vbs
' Adds a custom button to the Internet Explorer 5.0 toolbar
' -----------------------------------------------------------------------
rc = MsgBox("Would you like to add a new button to the toolbar?", vbYesNo)
if rc=vbNo Then WScript.Quit' The registry path where you add your new entries.
' If your registry doesn't contain a Shell node, it'll be silently created
REG_HKLM_IE50_BASE = "HKLM\Software\Microsoft\Internet Explorer\Extensions"' Adds a new key (needs a newly created GUID)
REG_HKLM_IE50_GUID = REG_HKLM_IE50_BASE & "\{10954C80-4F0F-11d3-B17C-00C0DFE39736}\"' Creates the required values
Set shell = WScript.CreateObject("WScript.Shell")
shell.RegWrite REG_HKLM_IE50_GUID & "ButtonText", "Run Script", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "MenuText", "Run Script", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "MenuStatusBar", "Run Script", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Clsid", "{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Default Visible", "Yes", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Icon", "C:\Program Files\Home.ro\icon1.ico", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "HotIcon", "C:\Program Files\Home.ro\icon2.ico", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Exec", "C:\Program Files\Home.ro\myprg.vbs", "REG_SZ"
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Sorry! My bad. It works fine.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
how to get the singel cell name in the sheet.
i = 1, j=2
Dim str As String
str = Cells(i, j).Name
I excepted str = "B1" but I got run time error...
Can anyone tell me why?
thanks
|
|
|
|
|
"B1" is not a cells name, that's it's position. You can give names to cells or a range of cells in Excel for the purpose of easing calculation. For example, if a cell has a value of 2.142.... and you name it PI, then in your formulas,you can refer to it as PI like so:
=B2 + PI which would make more sense.
So, the cell.name propert returns the name of the cell, not the position. If it doesn't have a name, you get a run-time error
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Thank you SMC,
Can you please tell me how to get the position of the particular cell. and can you also check my following incorrect code please. I'm trying to wait for the user to close the excel application after they done with whatever they have to do to the excel file. where am i getting wrong and how to fix it.
<br />
Dim idProc As Long<br />
Dim hProc As Long<br />
idProc = VBA.Shell("Excel", vbMaximizedFocus)<br />
hProc = OpenProcess(PROCESS_ALL_ACCESS, False, idProc)<br />
If hProc Then<br />
Do While WaitForSingleObject(hProc, 100) = WAIT_TIMEOUT<br />
<br />
DoEvents<br />
Loop<br />
CloseHandle hProc<br />
End If<br />
Thank you.
|
|
|
|
|
Hello Gurus...
I want the exiting excel file to open it, format it and print it.
opening and formating part I have ( mostly) done ... but to printing giving me problems.. when the file get print, there are lots of empty pages because of the last cell.
let's say, the sheet contain only two cells that has some data. the first cell is A1 and the last cell is z130 and there are no data in the cells between first and last cells.
So when I call PrintOut method it prints all the empty pages.
I'm trying to set the print area for the excel sheet because I don't want to print empty pages. But how can i set the print area only to print that two cells???
I tried look every cells whether if it is empty or not, if empty don't do anything but if not empty, set the range and set the printarea... the following is my code..I know it is wrong but don't know how to fix it
<br />
<br />
Function SetPrintArea(sheet As Worksheet) As Worksheet<br />
Dim r As Range<br />
Set r = sheet.UsedRange<br />
<br />
Dim newRange As Range<br />
Dim i As Integer<br />
Dim j As Integer<br />
<br />
For i = 1 To r.Rows.Count<br />
For j = 1 To r.Columns.Count<br />
If Not Cells(i, j).Value = "" Then<br />
newRange = newRange(Cells(1, i), Cells(i, j))<br />
End If<br />
Next j<br />
Next i<br />
newRange.Cells.Select<br />
sheet.PageSetup.PrintArea = Selection.Address<br />
Set SetPrintArea = sheet<br />
End Function<br />
Thanks
|
|
|
|
|
okay, I'm gonna ask the obvious question.... why are the only two cells in the sheet with the data so frikkin' far ????. That's gotta say something bout the design!
the Range object also accepts parameters in the form of a string, like so :
"A1:C5"
The above parameter would include everything from cells A1 to cells C5
But if you wanna do composite ranges, then the following string:
"A1:C5,D12:G7"
would include everything from the first string as well as everything from cell D12 to G7 and nothing in between.
I assume you could solve your problem by constructing the composite range string before hand, then pass it into the Range object
Hope that helps
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
You're damn right.. why do they do so?? Can't they just insert the information into the closer cells?? I, myself, want to know why they do that.. my job is to print that excel file..minimizing the number of pages that will print as possible.
Thank you for answer SMC, So how can i get the position of the cell?
Thank you
|
|
|
|
|