|
I was able to use the book as a reference, but what I had to do to get this interop to work was a bit different:
Private Sub btnCalculate_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCalculate.Click
1:
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim LoanPayment As Single
xlApp = CType(CreateObject("Excel.Application"), _
Microsoft.Office.Interop.Excel.Application)
LoanPayment = xlApp.WorksheetFunction.Pmt _
(txtInterest.Text / 12, txtMonths.Text, txtPrincipal.Text)
MsgBox("The Monthly Payment is " & _
Format(Abs(LoanPayment), "$#.##"), , "Mortgage")
xlApp.Quit()
End Sub
End Class
Why did I have to specify more precisely than the book suggested?
|
|
|
|
|
Try putting this at the top of your code:
Imports Microsoft.Office.Interop
You should then be able to make it look just like the book.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave.
The book was set up for use with Excel 2002, is there that big of a difference between Excel 10 and Excel 11?
Still coaxing software out of the can after all these years...
|
|
|
|
|
Yes, there is. Starting with Office XP, Microsoft is putting out Primary Interop Assemblies that allow for easier integration with .NET Framework apps.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Interesting. The book claims the lesson to be based upon using the Excel interop for Office XP. Since I'm in college, I went ahead and got Office Professional 2003 Academic. Skipped right over 2002/XP.
Additionally- I saw Visual Studio Tools for the Microsoft Office System 2003, and it was cheap, so I added that too.
Oh, and I can't thank you enough. I'm learning tons!
Still coaxing software out of the can after all these years...
|
|
|
|
|
The thing is that the book was referring to Office XP (2002). Whereas I was using Office 2003. My desktop is running Windows 2000 though.
I used the object browser to look up the specific Excel interop I was looking for and saw the pathing didn't match the book, so I copied the full path and pasted it in. The "little blue squigglys" went away.
I wonder what caused the discrepancy? Was it the book, or did I miss something somewhere?
Still coaxing software out of the can after all these years...
|
|
|
|
|
I've been working for this problem
when calling shellexeucte to launch outlook I specify hyperlink in
side of body, but when the hyperlink is too long it is not hyperlink
anymore instead just text. any workaround to avoid this problem
str_Body = "click here to there"
str_whole = "mailto:" & strEmailAddress & "?body=" & str_Body
ShellExecute Me.hWnd, "open", str_whole, vbNull, vbNull, SW_SHOWNORMAL
|
|
|
|
|
I have a TreeView and a ListView. My TreeView is used to browse through the computers file system. What I would like to do and just can’t seem to figure out how to make work is:
1-Open a file in the TreeView (I can do this now)
2-Display, in the ListView, any image(jpeg, tiff, etc.),as thumbnails, that are located in the file that is opened in the TreeView.
3-I would then like to be able to click on the thumbnail in the ListView and open the full image in a PictureBox. (I haven’t tried this yet)
Any comments or suggestions?
Thanks
Brad
|
|
|
|
|
You thumbnail view is better done with a grid of PictureBox's. The ListView control doesn't offer the kind of support your looking for, unless you want to write you own control and ownerdraw the ListView with pictures inside it.
Adding the PictureBox's to the form wouldn't be that hard. Even wiring up the Click event is easy enough using AddHandler and RemoveHandler to connect the event to a click method on your form.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
The ListView control doesn't offer the kind of support your looking for
...that is probably why I couldn't find any examples.
I'll see if I can figure out how to use the DataGrid.
As for the PictureBox, I was also thinking that-that part would be easy but I've learned to never say 'easy' until I've tried it.
Thanks Dave!
You have been a great help to me over the past few weeks.
Brad
|
|
|
|
|
Brad Fackrell wrote:
I'll see if I can figure out how to use the DataGrid.
...ooops, not DatGrid ...grid of PictureBoxes.
|
|
|
|
|
I want to take a belt and braces approach to avoiding SQL injection attacks. First step is to obviously used parameterised stored procedures. The second is to write a helper class to check input meets the expected format. To this end I'm thinking of writing a helper class that uses regular expressions.
<br />
Imports System.Text.RegularExpressions<br />
Public Class AntiSQLInjectionHelper<br />
<br />
Private Sub New()<br />
End Sub<br />
<br />
Public Shared Function CheckString(ByVal Value As String, ByVal [CheckType] As CheckType) As Boolean<br />
Dim pattern As String<br />
Select Case [CheckType]<br />
Case CheckType.DateString 'Checks for accepted date format<br />
pattern = "TODO"<br />
Case CheckType.General 'Checks for accepted general format (ie one that doesn't contain any DROP commands etc)<br />
pattern = "TODO"<br />
Case CheckType.NumberString 'Checks for accepted number format<br />
pattern = "TODO"<br />
Case CheckType.PasswordString 'Checks for accepted password format<br />
pattern = "TODO"<br />
Case CheckType.UsernameString 'Checks for accepted username format<br />
pattern = "TODO"<br />
End Select<br />
Return Regex.IsMatch(Value, pattern)<br />
End Function<br />
<br />
Public Enum CheckType<br />
DateString<br />
NumberString<br />
UsernameString<br />
PasswordString<br />
General<br />
End Enum<br />
<br />
End Class<br />
<br />
Has anyone out there got a better way / done anything similar, think its a good idea or know of an alternative? I know there are validation controls that use javascript but a dtermined hacker can circumvent them.
Jim
|
|
|
|
|
I've never written a class for this... I've always used the Validation controls in my UI code.
You might want to check out these two articles, here[^] and here[^], for an idea into using the Validation controls to do what your thinking of.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks very much I will look into the articles
Jim
|
|
|
|
|
You missed the most common solution - use command parameters. You don't need stored procedures to get auto-protection from SQL Injection.
Regular expressions are just overkill for this. For normal validation they are appropriate, but not at the database level.
In terms of what you are doing, one approach is to create data type classes with built in validation. It is an "ok" solution, and works pretty well with inheritance, e.g. DBTypeUserName can inherit from DBTypeString . There are downsides to this approach, such as performance (because you are no longer using value types).
Last point on validation - like you mentioned, client-side validation is unreliable. Always validate at least once more on the server-side. That said, the validation controls are harder to circumvent than you imply. The javascript is just one layer, the actual validation can be done on the code-behind, like:
Sub MySubmit_Clicked()<br />
Page.Validate()<br />
If Page.IsValid then<br />
...<br />
end If<br />
end Sub<br />
|
|
|
|
|
Ah I didn't consider command parameters and also traditional custom validation javascript can be circumvented but as you indicated with .NET its a bit more integrated. Thanks for your help, saves me writing unnecessary code.
Jim
|
|
|
|
|
Hi,
I am using the calendar control for the users to select a date. I need to restrict the dates they can select to 1st-28th of any month. Could anyone put me on the right lines please?
Cheers, V
|
|
|
|
|
You can't tell the Calendar control to restrict that. But, you can validate the dates that are selected and put up a Dialog that warns the user of the valid range to select, then clear out the Calendar control selection and start over.
Or, you could search the web for a 3rd party calendar control that offers that functionality. I don't know of any off the top of my head, but that doesn't mean they don't exist. I've just never had the need to find one.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Cheers,
I am quite new to asp.net and have tried to validate the dates but I can't figure out how to get the day of the selected date. I have looked at the getDayOfMonth method but I don't really understand how to use it (override it??).
Do you know of an example which uses it - have googled on it but having found anything
Cheers, V
|
|
|
|
|
OOhh!!! You didn't say you were using ASP.NET. The Calendar Web Server control WILL let you specify which days the user can pick. For the complete low down on the control, look here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Cheers. I ended up using the day property of datetime.
Thanks
V
|
|
|
|
|
Hi, i found how to get my application in system tray. The problem is when i want it to go in normal state. My app only want to go in maximize state. Here's my code
Private Sub Main_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
If Me.WindowState = FormWindowState.Minimized Then
TrayIcon.Visible = True
Me.ShowInTaskbar = False
End If
End Sub
Private Sub TrayIcon_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrayIcon.Click
'Ouvre l'application main window si on click sur l'icon dans le tray
Me.ShowInTaskbar = True
Me.WindowState = FormWindowState.Normal
TrayIcon.Visible = False
Me.Show()
End Sub
Thx in advance!
|
|
|
|
|
That's ok i found the solution
When the window is minimize i don't have to put Me.ShowInTaskbar = False. The app in task bar automaticaly disapear
so here's the code
Private Sub Main_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
'Si minimize, on met l'application en Systemtray
If Me.WindowState = FormWindowState.Minimized Then
TrayIcon.Visible = True
Me.Visible = False
End If
End Sub
Private Sub TrayIcon_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrayIcon.Click
'Ouvre l'application main window si on click sur l'icon dans le tray
Me.Visible = True
Me.WindowState = FormWindowState.Normal
TrayIcon.Visible = False
End Sub
Enjoy
|
|
|
|
|
I'm trying to create a Windows Form that has a folder browser control on it, exactly like the VB.NET FolderBrowserDialog, but I also need to add some of my own custom controls onto the same form. So for this reason I can't just pop-up the FolderBrowserDialog - I need it present within my form.
But I can't find a way of adding the FolderBrowserDialog, or its individual components on to my form. Is this possible?
All I can find are controls like the DirListBox and DriveListBox, but I want to recreate the kind of browse dialog you'd see as standard in Windows, with buttons allowing the user to toggle View, Create New Folder, navigate back etc.
Thanks very much for any help,
Mark
|
|
|
|
|
Mark Phanides wrote:
But I can't find a way of adding the FolderBrowserDialog, or its individual components on to my form. Is this possible?
No, it's not. But, you could create your own version of the dialog by inheriting from CommonDialog and adding the controls you want. To find out how the FolderBrowserDialog works, you can use .NET Reflector[^] to disassemble the code in the FolderBrowserDialog class and examine how that implementation works.
Now, with the standard FolderBrowserDialog, the user just has to right-click in the folder list to get the context menu and create a New/Folder, or you could just set the NewFolderButton property to True to tell the Dialog to display one itself. Navigate back is easy enough with the folder path dropdown list at the top of the dialog.
But, I don't know what you mean by "toggle view"? What view?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|