Jump to content
Xtreme .Net Talk

mark007

Avatar/Signature
  • Posts

    185
  • Joined

  • Last visited

Everything posted by mark007

  1. Ok, I have a couple of queries: 1. Is this really an asp.net application? In that case the code is running on a webs server and will open Excel on the webserver rather than client machine.. 2. When you first run it how many excel instances are in the task manager? When you run-it again how many are there? 3. Does it ever work in this problem PC e.g. on the first occasion? A couple of other points. When automating Excel (in fact really it's always good practice) it's best to ensure Option Strict is set. To will make sure all your object assignments are valid and give the asddeed advantage of axtra intellisense. Also when you post your code enclose it in [vb ][/ vb] tags (less the spaces) to format your code as in my post above. :)
  2. I would suggest something like: //global variable Boolean blLoading = false; // Fill Client ComboBox cbAssignment.Enabled = false; blLoading=true; cbClient.DataSource = ds; ... configure cbClient ... cbClient.SelectedIndex = -1; blLoading=false; } private void cbClient_SelectedIndexChanged(object sender, System.EventArgs e) { if (!blLoading) { // Load all corresponding Assignments ... load the data into cbAssignment depending on the current selected value in cbClient cbAssignment.Enabled = true; } } You have to excuse any bad syntax as VB is my game ;) :)
  3. Really I think it boils down to what the problem is as to which solution is best..if any. A rethink of the way the app works may in the end be the ultimate solution!
  4. Try a small modification of wayne's code: Private Sub dgRecs_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _ Handles dgRecs.ItemDataBound If IsDate(e.Item.Cells(8).Text) Then 'Replace the index with the column of your Edit Column ctype(e.Item.Cells(0).Controls(0),linkbutton).Visible=false End If End Sub I would also place a debig point in the code and check the values are as you expect in e.Item.Cells(8).Text for example. :)
  5. Without seeing your full code it's hard to say but I would suggest it's probably one of: 1. Hidden references Make sure that your code does not make any references to intrinsic VBA objects such as Activesheet etc. but instead references them via the application object e.g. xlApp.Activesheet 2. Not disposing of the COM components satisfactorily Make sure you dispose of any global COM references properly using a function such as: Private Sub DisposeObject(ByVal obj As Object) Dim count As Integer Try If obj Is Nothing Then Exit Try count = Marshal.ReleaseComObject(obj) While count > 0 count = Marshal.ReleaseComObject(obj) End While Catch ex As Exception Finally obj = Nothing End Try End Sub :)
  6. You want to use the RegisterHotKey API I think though I've never used it myself. The below is a VB6 example from API guide: Private Const MOD_ALT = &H1 Private Const MOD_CONTROL = &H2 Private Const MOD_SHIFT = &H4 Private Const PM_REMOVE = &H1 Private Const WM_HOTKEY = &H312 Private Type POINTAPI x As Long y As Long End Type Private Type Msg hWnd As Long Message As Long wParam As Long lParam As Long time As Long pt As POINTAPI End Type Private Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long Private Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long) As Long Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long Private Declare Function WaitMessage Lib "user32" () As Long Private bCancel As Boolean Private Sub ProcessMessages() Dim Message As Msg 'loop until bCancel is set to True Do While Not bCancel 'wait for a message WaitMessage 'check if it's a HOTKEY-message If PeekMessage(Message, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then 'minimize the form WindowState = vbMinimized End If 'let the operating system process other events DoEvents Loop End Sub Private Sub Form_Load() 'KPD-Team 2000 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email]KPDTeam@Allapi.net[/email] Dim ret As Long bCancel = False 'register the Ctrl-F hotkey ret = RegisterHotKey(Me.hWnd, &HBFFF&, MOD_CONTROL, vbKeyF) 'show some information Me.AutoRedraw = True Me.Print "Press CTRL-F to minimize this form" 'show the form and Show 'process the Hotkey messages ProcessMessages End Sub Private Sub Form_Unload(Cancel As Integer) bCancel = True 'unregister hotkey Call UnregisterHotKey(Me.hWnd, &HBFFF&) End Sub Clearly you will need to modify it to work with .net. :)
  7. You can only do with vbscript on the client side (works in IE only) embedded in the page orn through an activex control. In both cases they would get a security warning. Depending on what you are trying to do it might be better to craete the spreadsheet server side and then provide it as a download.. :)
  8. Or use recursion to get all the controls: CheckBoxes(Me) Private Sub CheckBoxes(ByVal Parent As System.Windows.Forms.Control) dim c As System.Windows.Forms.Control For Each c In Parent.Controls CheckBoxes(c) If TypeName(c) = "CheckBox" Then CType(c, CheckBox).Checked = True End If Next End Sub :)
  9. Rofl@hjb :D
  10. Is this a javscript or asp.net error? Have you made sure your dropdown is declared?
  11. I would have a global boolean blRunning that you set to true when the file processing code starts and false when it finishes. When each file is added to the listbox I would check if blRunning is false and if so call the file processing code. The file processing code, once finsihed with one file should then check if the listbox has any items still in it and if so process another one. In this way the fileprocessing code will run until the listbox is empty and then start up again when another file is added. :)
  12. Or to throw another way: Dim c As System.Windows.Forms.Control For Each c In Me.Controls If TypeName(c) = "CheckBox" Then CType(c, CheckBox).Checked = True End If Next :)
  13. It is fairly involved. You do it using templates. personally I don't like using pseudohtml templates in aspx pages - I like to build my own template classes. Here is an example of one I made to show either true or false in a dropdown on edit: Public Class MyDropDownTemplate Implements ITemplate Private m_data As String Private m_read As Boolean Public Sub New(ByVal DataSource As String, ByVal [ReadOnly] As Boolean) m_data = DataSource m_read = [ReadOnly] End Sub Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn If m_read Then Dim l As New System.Web.UI.WebControls.Literal AddHandler l.DataBinding, AddressOf Me.DataBind container.Controls.Add(l) Else Dim dl As New System.Web.UI.WebControls.DropDownList AddHandler dl.DataBinding, AddressOf Me.DataBind 'now add the items to the list dl.Items.Add("True") dl.Items.Add("False") container.Controls.Add(dl) End If End Sub Private Sub DataBind(ByVal sender As System.Object, ByVal e As System.EventArgs) If m_read Then Dim l As System.Web.UI.WebControls.Literal = CType(sender, System.Web.UI.WebControls.Literal) Dim container As DataGridItem = CType(l.NamingContainer, DataGridItem) Dim DRV As DataRowView = CType(container.DataItem, DataRowView) l.Text = CType(DRV(m_data), String) Else Dim dl As System.Web.UI.WebControls.DropDownList = CType(sender, System.Web.UI.WebControls.DropDownList) Dim container As DataGridItem = CType(dl.NamingContainer, DataGridItem) Dim DRV As DataRowView = CType(container.DataItem, DataRowView) 'determine the selected item If CType(DRV(m_data), String).ToLower = "true" Then dl.SelectedIndex = 0 Else dl.SelectedIndex = 1 End If End If End Sub End Class You then add the column to your datagrid using: Dim t As New System.Web.UI.WebControls.TemplateColumn With t .HeaderText = "Col Header" .ItemTemplate = New MyDropDownTemplate("DataFieldName", True) 'displaying items is always read only .EditItemTemplate = New MyDropDownTemplate("DataFieldName", False) .Visible = True End With .Columns.Add(t) :)
  14. I would loop through the controls on the form and check the type of the control. If it's a checkbox then check it. :)
  15. A while since you posted but oh well... I would use: ((19|20)[90][0-9](0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])[0-9]{4})[0-9]{2} i.e. extended your regex slightly then use the spit function. The splits you want will be the first, second and last. :)
  16. How are you loading the image viewer from the VB app?
  17. It certainly is. You want to look into System.Net.Sockets.TcpClient and the POP3 protocol. Do a google search and I'm sure some examples will come up. :)
  18. I use the following: Private Sub DisposeObject(ByVal obj As Object) Dim count As Integer Try If obj Is Nothing Then Exit Try count = Marshal.ReleaseComObject(obj) While count > 0 count = Marshal.ReleaseComObject(obj) End While Catch ex As Exception Finally obj = Nothing End Try End Sub Which I found somewhere when first reading up on Excel automation through .Net. You basically need to call it on all objects when you're done with them. :)
  19. What sort of file is it? I have an article on my site here that deals with excel files: http://www.thecodenet.com/articles.php?id=9
  20. You could look into adjusting how you are doing things and using AJAX. A page with some javascript on it displays the wait message while a call is made to get the data in the background to another asp page. This page caches the data under a guid and returns the guid to the calling javascript. The javascript can then redircet to the page displaying the data passing the guid in the query string for the page to get the data from the cache. Another possibility that might work is displaying "Please wait.." at the top of you page then calling Response.Flush to output that to the browser. The rest of the page could then load as normal. You could even put some javascript that is called when it has loaded to hide the please wait. You could also look into adjusting how you are displaying data perhaps implemeting a custom paging setup to avoid downloading all the data every time. :)
  21. I have a picturebox on a form that displays a transparent gif all fine and well. I wish to copy this to the clipboard so I can paste it elsewhere. Unfortunately using the following: System.Windows.Forms.Clipboard.SetDataObject(f.PictureBox2.Image) Replaces the transparency with a dark blue. Any ideas on how I can achieve this? :)
  22. Thanks for the reply though I'm not sure how that helps me... I have created the code for my service - a cut down version being: Public Class ETUpdaterService Inherits System.ServiceProcess.ServiceBase Private WithEvents m_timer As New System.Timers.Timer Protected Overrides Sub OnStart(ByVal args() As String) 'this is where we start the checking for updates m_timer.Interval = 600000 'every 10 minutes m_timer.AutoReset = True m_timer.Enabled = True End Sub Protected Overrides Sub OnStop() 'stop the timer m_timer.Enabled = False End Sub Private Sub m_timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) _ Handles m_timer.Elapsed m_timer.Enabled = False 'check to see if there are any updates m_timer.Enabled = True End Sub Protected Overrides Sub OnCustomCommand(ByVal command As Integer) m_timer.Enabled = False If command = 255 Then 'force the app to download new updates End If m_timer.Enabled = True End Sub End Class 'Now comes installation class <RunInstaller(True)> Public Class ServiceInstaller Inherits System.Configuration.Install.Installer #Region " Component Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Installer overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Component Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Component Designer 'It can be modified using the Component Designer. 'Do not modify it using the code editor. Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller ' 'ServiceProcessInstaller1 ' Me.ServiceProcessInstaller1.Account = ServiceProcess.ServiceAccount.LocalSystem Me.ServiceProcessInstaller1.Password = Nothing Me.ServiceProcessInstaller1.Username = Nothing Me.ServiceInstaller1.DisplayName = "ETUpdaterService" Me.ServiceInstaller1.ServiceName = "ETUpdaterService" Me.ServiceInstaller1.StartType = ServiceProcess.ServiceStartMode.Manual ' 'ProjectInstaller ' Me.Installers.AddRange(New System.Configuration.Install.Installer() _ {Me.ServiceProcessInstaller1, Me.ServiceInstaller1}) End Sub #End Region End Class I created this in a windows console app for the time being. Clearly though there isn't a sub main. I would be intrigued to see the output of the vbproj file for a service to see how it is setup and if changing the relevant entries will fool vb.net standard into creating a windows service. So again any ideas as to how it could be done and why it needs to be an exe. For instance if I compile it as per a library would it still install as a service with installutil? Or perhaps if I compile as an exe (ie. console app) with no code in sub main it would install and run correctly? :)
  23. I'm sure it must be doable by changing some of the settings in the project file for a console app as per creating a class library. Given class library changes are: OutputType="exe"==>OutputType="library" StartupObject = "Module1"==>StartupObject = "" I'm thinking that I probably just need to change the startup object to "" and create the standard ServiceBase and installer clases needed for a service. Any thoughts? I was also wondering whether there is any reason for a service to be an exe rather than dll? Thanks. :)
  24. Ok, well I've got round it by just reading the html as a text file. Would still be interested on any information on the problem though. :)
  25. I have an asp.net application that is mainly a front end to a database. For some of the tables there is some text that accompanies it that I don't really want to store in the database but want to include on the web page. The pages containing the text are simple html pages in the same folder as everything else so I was inluding them using: Try Dim l As New Literal Dim textWriter As New System.IO.StringWriter Server.Execute(strTable & "info.htm", textWriter) l.Text = textWriter.ToString() & "<br><br>" Me.phGrid.Controls.Add(l) Catch ex As Exception strError=ex.ToString End Try This all looked fine. The problem though is that now my postbacks don't work and nothing is displayed. If I comment out the server.execute then the pages work fine but without the included files. If I enclose it in a if not me.ispostback then it still doesn't work... Afetre searching the net it seemed to be a documented issue fixed by this service pack: http://www.microsoft.com/downloads/details.aspx?familyid=A8F5654F-088E-40B2-BBDB-A83353618B38&displaylang=en But installing di not solve the problem. Therefore does have anyone have any ideas on how to a) solve it or b) use something else to the same effect. Thanks. :)
×
×
  • Create New...