|
Could somebody help me to format a field in crystal report.
I have a field named "Code" with value is 9393. However, I want to add 0000 in front of it, then it would become: 00009393. I know that in crystal report that have a string function called length and ReplicateString, so that we can use to add 0000 in front of a number. I know the way to do it, but I don't know how to write it in "Format Formula Editor". Could anyone help me on this? thanks.
John
|
|
|
|
|
if u are using Crystal Rerpots 9.0 then click on view menu select field explorer. from field explorer right click on formula fields and select new.
enter the name of the formula. then a new window will appear. in the editor just write
"0000" & Code
it will do the required thing save it and close it drag the field from the formula fields to the report.
hopefully it will help
computer... Programming... whats that
|
|
|
|
|
Thank you. It really helps.
|
|
|
|
|
How is this coded in visual basic 6? I have gotten everything but this.
copy coversheet1 from test.xls in c:\test directory
paste or create coversheet1 to test2.xls in c:\test2 directory
both excel documents exist but I need to transfer a sheet from one document to the other.
Any help would be greatly appreciated.
Thanks
Beginner in VB.Net
|
|
|
|
|
Actually, your question has nothing to do with VB. Rather, it's a question of knowing Excel object model, which I'm not that great with.
After a cursory search through MSDN, I couldn't find a Copy method in the Worksheet object documentation.
In theory, you'll have to open both workbooks in your Excel object (I'm not even sure this is possible!) Call some kind of copy method on the Worksheet object you're copying from and give it the workbook name to copy the sheet to. You'll probably also have to give it the name of a worksheet in your destination workbook so the Copy method knows where to put the copy in the worksheet order.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
This is what i got form MSDN ....................
You can add one or more worksheets to the Worksheets collection by using the collection's Add method. The Add method returns the new Worksheet object. If you add multiple worksheets, the Add method returns the last worksheet added to the Worksheets collection. If the Before or After arguments of the Add method are omitted, the new worksheet is added before the currently active worksheet. The following example adds a new worksheet before the active worksheet in the current collection of worksheets:
Dim wksNewSheet As Excel.Worksheet
Set wksNewSheet = Worksheets.Add
With wksNewSheet
' Work with properties and methods of the
' new worksheet here.
End With
You use the Worksheet object's Delete method to delete a worksheet from the Worksheets collection. When you try to programmatically delete a worksheet, Microsoft® Excel will display a message (alert); to suppress the message, you must set the Application object's DisplayAlerts property to False, as illustrated in the following example:
Function DeleteWorksheet(strSheetName As String) As Boolean
On Error Resume Next
Application.DisplayAlerts = False
ActiveWorkbook.Worksheets(strSheetName).Delete
Application.DisplayAlerts = True
' Return True if no error occurred;
' otherwise return False.
DeleteWorksheet = Not CBool(Err.Number)
End Function
Note When you set the DisplayAlerts property to False, always set it back to True before your procedure has finished executing, as shown in the preceding example.
You can copy a worksheet by using the Worksheet object's Copy method. To copy a worksheet to the same workbook as the source worksheet, you must specify either the Before or After argument of the Copy method. You move a worksheet by using the Worksheet object's Move method. For example:
Worksheets("Sheet1").Copy After:=Worksheets("Sheet3")
Worksheets("Sheet1").Move After:=Worksheets("Sheet3")
The next example illustrates how to move a worksheet so that it is the last worksheet in a workbook:
Worksheets("Sheet1").Move After:=Worksheets(Worksheets.Count)
I hope this will help u................:->
Regards,
Ritesh
|
|
|
|
|
Ritesh1234 wrote:
You can copy a worksheet by using the Worksheet object's Copy method. To copy a worksheet to the same workbook as the source worksheet, you must specify either the Before or After argument of the Copy method.
I am trying to copy a worksheet from one workbook to another workbook. From what I get from you is, copying a worksheet in the same workbook and not to a totally different workbook.
I was able to add a sheet to the workbook but that doesn't solve the problem of copying the data over to it.
This is my task. I am creating an excel document in Visual Basic code with 6 worksheets. Now I need to be able to create another sheet making it the cover sheet for that work book. I have another excel file that acts like a template as to what the cover sheet should look like. I need to copy that worksheet containing the cover sheet to the new file I created in visual basic. EX:
Test.xls contains coverSheet
Test2.xls contains 6 worksheets
I need to take the coverSheet from test.xls and put that worksheet into test2.xls
Is it possible to copy from one workbook to another different workbook?
Thanks for the help
Beginner in VB.Net
|
|
|
|
|
hi,
Did u tried with worksheet.Add method????
|
|
|
|
|
Hi Ppl,
I would like to populate my datagrid with just the months in vertical order with the datasource from a dataset.
From my dataset I can get 2 col namely QtyOrdered and QtyTaken
But I would like to display these for 12 month period as shown below
Month QtyOrdered QtyTaken Difference
Jan 10 20 +10
Feb 20 10 -10
Mar 30 10 -20
...
...
Dec 50 20 -30
Can I do this in my SQL statement or do I have to do this at grid popluation?
Tnx
|
|
|
|
|
I'm a relatively new programmer so I hope that I can explain this well.
I use the following variable assignment to pass through a sql string:
FormatDate = Format(#12/31/2003#, "dd-MMM-yyyy")
This works for me, but when I replace the hardcoded date with a variable that is assigned to a text box (for user input), I get an error msg (ORA-01847).
FormatDate = Format(Session("1"), "dd-MMM-yyyy")
Any thoughts?
Thanks in advance.
|
|
|
|
|
I'm assuming VB.NET here... You didn't say which version of VB you were using.
Drexel GG wrote:
FormatDate = Format(#12/31/2003#, "dd-MMM-yyyy")
The #12/31/2003# is a value of type Date . This is a Visual Basic primitive type that maps onto the .NET Framework runtime type called DateTime , which is really a structure. The Format function can easily convert this value into the format that you specify because it can call the DateTime structure's .ToString() method do the conversion.
Drexel GG wrote:
FormatDate = Format(Session("1"), "dd-MMM-yyyy")
I'm assuming Session("1") returns a String type. You haven't provided enough code or information to make this determination. But, if Session("1") is a String type, then the Format function has no way of determining that this is a date and has no idea how to convert it to one.
You'll have to try and Parse the Session("1") String and create a DateTime object out of it in order to pass this to the Format function.
Dim myDate As DateTime
Try
myDate = DateTime.Parse(Session("1"))
FormatDate = Format(myDate, "dd-MMM-yyyy")
Catch ex As Exception
' It's possible that the date isn't in the correct format.
' If that's the case, we'll end up here.
End Try
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am in fact using VB.Net. thanks for your suggestions -- I've been able to make things work now. You were correct Session("1") is a string type.
Thanks again.
|
|
|
|
|
Hi all!
I am working on an application which shall access a database through some datasets, and allow manipulation of the datasets by datagrids on several forms.
To keep the project some kind of tidy we would like to put all the dataset-definitions, dataadapters and database connections in one component class, or something like that.
My first question would be: is a component class the right tool for this?
The second question is a little more complex: As i understand it, in our component class we have only definitions of the dataset, but no objects. Now we could write some code to instantiate objects of the datasets, fill them by dataadapters, and bind them to grids. But for some reasons we would like to do this step by designer. Is this possible somehow?
Thanks for your time,
Markus
|
|
|
|
|
Hi guys, im trying to get the selected text of the active window and set it to the clipboard. I tryed this code but doesn´t run.
'I declare the GetForegroundWindow and SendMessage Functions
'Then I call by this:
SendMessage(GetForegroundWindow(), WM_COPY, 0, &0)
Do someone know what is wrong and how to do it?
Thanks to all!!
|
|
|
|
|
This isn't enough code to tell you what's wrong. We definately need the declarations of the functions your using and the constants you defined. Also, are you using VB6 or VB.NET?
Another question I have is how is this code getting launched? Do you have to click a button or hit some keys on your application to get this code to run. This would now make the Foreground window your application, not the one probably thinking of.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave, first of all thaks for your help!!
My code is in Vb.NET, and to get an idea of the functionality, it is an app that runs in the sysTray and has some global hotkeys defined(allready). So an exactly example would be that if I have the notepad open with some text selected, I can press this hotkey to copy the text. The hotkey capture is done and filtered by a case, so from here I call the sendMessage(). The code is something like this:
Public Const WM_COPY = &H301
Private Declare Function GetForegroundWindow Lib "user32" () As intPtr
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As intPtr, ByVal uMsg As Long, _
ByVal wParam As integer, ByVal lParam As integer) As Long
'Now I call the sendMessage function from the case
case...
SendMessage(GetForegroundWindow(), WM_COPY, 0, &0)
One important thing is that if I pass the handle of one textbox of my app, it runs! like this: SendMessage(Me.TextBox.Handle, WM_COPY, 0, &0)
And the way that I know (or think) that getForegroundWindow is working is because if I try with different active windows, the handle that returns this function, change.
The point I think where could be the problem is that I don't know if the handle of the active window is sufficient to let the WM_COPY knows where is the selected text to copy. Would be necesary to specify the edit control in the active window that has the selected text, as I did with "Me.TextBox.Handle" ?? If so, I don't know how to find the edit control that has the selected text in the active window.
Well Dave, thank you in advance for your help.
Bye
Damian
|
|
|
|
|
dcastroviejo wrote:
Would [it] be necesary to specify the edit control in the active window that has the selected text, as I did with "Me.TextBox.Handle" ?? If so, I don't know how to find the edit control that has the selected text in the active window.
Yes, WM_COPY must be sent to the edit control handle, not the parent window. There is really no way of determining which edit control has the focus.
Applications that let you drap a cross hair around the screen and see each and every window, including edit controls, use the function ChildWindowFromPoint to get the window handle. This won't work in your case because you really cant get a reliable point to pass to this function.
Also, you can't enumerate the child windows of a window to find the edit control because there are so many different window classes that can process this message, you can't just send the message to all the child windows. Each window will overwrite the previous windows data on the clipboard.
An alternative, since you have the parent windows handle, is to send the Ctrl-C keyboard sequence. It's pretty much universal that Ctrl-C means "Copy" in any application. Check into the WM_KEYDOWN and WM_KEYUP messages.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
OK, I'll investigate on this WM_KEYDOWN and WM_KEYUP messages.
I'll let you know when this run!
Thanks about the info !
|
|
|
|
|
I have a MS Access 2003 report that simply displays data from columns in one Access table. One of the columns is called Amount. The Report Footer displays the Total on a text box calculated as Sum(Amount) and works fine.
I want to display the Amount subtotal for each page but when I assign
Sum(Amount) to a textbox in the Page Footer I get an error at runtime.
How can I display the subtotal of Amount column on each page??
(I cannot group as the records have nothing in common)
1fm1fu
|
|
|
|
|
And this has what to do with VB/VB.Net? So far, you haven't mentioned any code problems you might be having. Just something with the Report Designer in Access. You might want to try finding an Access Forum for this question.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi everybody... I got a short question about one nasty little API function which I am in most dire need of. I need to somehow update the translucency / transparency setting of a normal window. Say I got two buttons and a Scrollbar. I need to somehow call the UpdateLayeredWindow function each time the scrollbar is modified so I can modify the translucency (opacity) level of my window. So far, I need to DESTROY and create the window AGAIN and use "SetLayeredWindowAttributes" to achieve this. But it's not a solution, this is a workaround and it's not nice at all : ), I think you agree : ).
Here's what I got so far... (this is VB6 code, but any language will do, I can adapt to anything, the only thing that I need is to actually make this WORK : ) ).
<br />
UpdateLayeredWindow Me.hwnd, Me.hdc, ByVal 0, m_windowSize, m_mainSurfaceDC, <br />
m_srcPoint, 0, m_blendFunc, ULW_ALPHA
You don't have to care about the parameters. My question is not related to those. My question is... can this nasty function be used to set a NORMAL WINDOW? I mean not a bitmap! A window... with some buttons and stuff on it. I am sure it must be possible, but I just don't know how. It's one nasty little function and I can't find anywhere some good documentation about it, only examples that are not working properly or do more than I need this function to do. I Googled for it and 60% of the results were declaring it, but not using it ! HA! Imagine that! : (. The other 40% were either using bitmaps, either not working.
I got one example that uses bitmaps, but that's too complicated and it's not what I need. I tried to put a scrollbar on that window and it wouldn't even appear, of course, since the guy who did this is using some bunch of functions to work with the bitmaps : (.
Thank you a LOT for reading this and I would really appreciate any help, it's for a good cause : ) (freeware application). I sure hope there are some people on the Code Project who ran into this function before.
Just before you ask... no, I can't use .Net to do this, but some .Net ideas WOULD be usefull since I could at least port it to my VB 6.
Have a nice day everybody : )
The Greater Mind Balance
|
|
|
|
|
1) Cross posting in multiple forums on the same site is considered very rude!
2) Posting VB code and asking VB questions in a C# or C++ Forum could get you strung up by your nads! Be prepared to receive much abuse.
3) You can't use the UpdateLayeredWindow function on a VB6 created window because the WS_EX_LAYERED attribute is not set when VB6 creates its windows. You'll have to modify the window after it's created in order to use this function. See this[^] article on BuilderAU.com for an example of how to do this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm sorry for posting in both groups, but as my question was a general one, I wanted more programmers to see it. Not all C# programmers look in the Visual Basic.Net area and not Visual Basic.Net programmers look in the C# area. I just wanted to cover both groups : ). I don't find this very rude, but I do apologize and I will not do this again.
Thank you for your answer, but you didn't read my message carefully I think. I already achieved all that. SetWindowLong, SetLayeredWindowAttributes are working. I already have my LayeredWindow, but the problem is that I don't know how to use that tricky UpdateLayeredWindow function. I ran through the whole MSDN documentation about that function and lots of examples from the internet but as I said, they are using bitmaps and stuff, and I only want to use that function on the HDC of my window but without bitmaps and things like that. I just want to use it to dinamically change translucency without having to destroy and re-create the window.
Thank you : )
The Greater Mind Balance
|
|
|
|
|
Actually, I did read your message and the question was this:
My question is... can this nasty function be used to set a NORMAL WINDOW?
The answer to that question is No. But, like you said, the window must be modified before you can call this function.
Also, you said:
You don't have to care about the parameters.
Actually, when people start posting questions about why API calls don't work, it's because the parameters are screwed up. We'd need to see you declaration for UpdateLayeredWindow , your structure definitions that are used by it, the code the fills in these structures, and the code that sets up the call to UpdateLayeredWindow. Without that, you're hiding the small details that can make all the difference in the world.
From what I've seen in other source code, this isn't very complex.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Haha. You're ok : ). You are kind of right. Let me just ask this question: do I need to use a bitmap to use that function (I guess no... but I'm asking just to be sure). And another question: did you come across that function and used it until now?
Hey, for all the trouble I gave you, I'll make it up by making an article about using this function (when and if I'm gonna make it work) in both C# and VB.Net, so I can wash my cardinal sin of cross posting : D, haha. Happy ? : ). Have a nice day mate! : ).
The Greater Mind Balance
|
|
|
|
|