|
If they all have individual databases then that does complicate matters a little (I originally thought of a shared database) ... not sure how you are going to be able to grant access to other files that way
|
|
|
|
|
If Focus is on DataGridview if Escape key is pressed then set focus to textbox1
If Focus is not on DataGridview if Escape key pressed then i want to close the form
how do? please help me.
|
|
|
|
|
|
I have used this code to access the webcam of my laptop and it perfectly works, but once i try to open it in my tablet it just shows me a black screen, the same thing happen when i test the code with a PC that does not have a webcam!
ANY IDEAS?
Dim hCap As Long
Private Sub cmd4_Click()
Dim sFileName As String
Call SendMessage(hCap, wm_cap_set_preview, CLng(False), 0&)
With CDialog
.CancelError = True
.Flags = cdlOFNPathMustExist Or cdlOFNOverwritePrompt
.Filter = "Bitmap Picture(*.bmp)|*.bmp|JPEG Picture(*.jpg)|*.jpg|All Files|*.*"
.ShowSave
sFileName = .FileName
End With
Call SendMessage(hCap, WM_CAP_FILE_SAVEDIB, 0&, ByVal CStr(sFileName))
DoFinally:
Call SendMessage(hCap, wm_cap_set_preview, CLng(True), 0&)
End Sub
Private Sub Cmd3_Click()
Dim temp As Long
temp = SendMessage(hCap, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
End Sub
Dim hwdc As Long
Dim startcap As Boolean
Private Sub cmdCapture_Click()
Dim temp As Long
hCap = capCreateCaptureWindow("Take a Camera Shot", ws_child Or ws_visible, 0, 0, PicWebCam.Width, PicWebCam.Height, PicWebCam.hWnd, 0)
If (hwdc <> 0) Then
temp = SendMessage(hwdc, wm_cap_driver_connect, 0, 0)
temp = SendMessage(hwdc, wm_cap_set_preview, 1, 0)
temp = SendMessage(hwdc, WM_CAP_SET_PREVIEWRATE, 30, 0)
startcap = True
Else
MsgBox ("No Webcam found")
End If
End Sub
Private Sub Cmd2_Click()
Dim temp As Long
temp = SendMessage(hCap, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
End Sub
Private Sub Form_Load()
cmd1.Caption = "Start &Cam"
cmd2.Caption = "&Format Cam"
cmd3.Caption = "&Close Cam"
cmd4.Caption = "&Save Image"
End Sub
|
|
|
|
|
I created a simple application that uses an interface to implement MEF (and yes its a stupid and simple example, or so I thought):
Imports System.ComponentModel.Composition
<InheritedExport(GetType(IMathFunctions))>
Public Interface IMathFunctions
Function DoMath(ByVal Num1 As Double, ByVal Num2 As Double) As Double
End Interface
So In the same project I have one class that uses the interface:
Imports WpfImportedFiles
Imports System.ComponentModel.Composition
<Export(GetType(WpfImportedFiles.IMathFunctions))>
Public Class Substract
Implements WpfImportedFiles.IMathFunctions
Public Function DoMath(Num1 As Double, Num2 As Double) As Double Implements IMathFunctions.DoMath
Return (Num1 - Num2)
End Function
End Class
And I load this into the program using this code:
Imports System.Collections.Generic
Imports System.Linq
Imports System.ComponentModel.Composition
Imports System.ComponentModel.Composition.Hosting
Imports System.Reflection
Imports System.IO
Public Class Importer
<ImportMany(GetType(IMathFunctions))>
Private operations As IEnumerable(Of IMathFunctions)
Public Sub DoImport()
Dim catalog = New AggregateCatalog()
Dim asm = Assembly.LoadFrom("C:\Users\ ... \LibImportedClasses.dll")
Dim catalog2 As New AssemblyCatalog(asm)
Dim catalog3 As New AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly())
catalog.Catalogs.Add(catalog3)
catalog.Catalogs.Add(catalog2)
Dim container As New CompositionContainer(catalog)
container.ComposeParts(Me)
End Sub
Public ReadOnly Property AvailableNumberOfOperations() As Integer
Get
Return (If(operations IsNot Nothing, operations.Count(), 0))
End Get
End Property
Public Function CallAllComponents(a As Double, b As Double) As List(Of Double)
Dim result = New List(Of Double)()
For Each op As IMathFunctions In operations
result.Add(op.DoMath(a, b))
Next
Return result
End Function
End Class
This works well for the class that is inside the original project, except for one thing; It gets loaded twice, and I don't understand why.
The other question is, how do I load a lib file that is in a separate project (i.a. the interesting case). I could not get it to work, but managed to load the assembly, that did contain the class I wanted to load, but I couldn't use it.
I hope that you could assist me in answering the two (hopefully) simple questions.
|
|
|
|
|
Because the InheritedExport AND the Export attributes export it. Remove the InheritedExport on the interface to fix it.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I couldn't make that work, but I could keep it in the interface and remove it from the classes, that way only one instance was created. So thank you for your help
But I still can't add the method created in the separate project.
|
|
|
|
|
There is just one problem left, I can't seem to load the Assembly from the imported dll. But I am able to get the type that Im interested in by using this method:
Dim Path As String = ("C:\Users\ ... WpfPlayingAroundWithMEF\LibImportedClasses\bin\Debug")
Dim pluginFiles() As String = Directory.GetFiles(Path, "*.dll")
Dim ipi = (From file In pluginFiles
Let asm2 = Assembly.LoadFile(file)
From type In asm2.GetExportedTypes()
).ToArray()
So why doesn't the lines:
Dim asm = Assembly.LoadFrom("C:\Users\ ... LibImportedClasses\bin\Debug\LibImportedClasses.dll")
Dim catalog2 As New AssemblyCatalog(asm)
Load the assembly so I can use them?
Edit:
My other project lib looks like this:
Imports System.ComponentModel.Composition
Imports WpfImportedFiles
Public Class Add
Implements WpfImportedFiles.IMathFunctions
Public Function DoMath(Num1 As Double, Num2 As Double) As Double Implements IMathFunctions.DoMath
Return Num1 + Num2
End Function
End Class
I have tried to add the Export attribute, but that seems to be provided by the inheritedexport in the interface.
modified 8-Oct-15 2:31am.
|
|
|
|
|
I don't know what the issue was, but a rebuild of the library fixed it.
|
|
|
|
|
i have added a button named book, and a panel below it.when mouse will hover over book button the panel will be visible (i used increment of panel height for this).but my requirement is, the panel to be visible as long as the mouse hover over the panel.
if u can't under stand what i'm saying just check this page..
flipkart. check the header menu which contains electronics, men, women etc.
i want that type of menu in my form. i hope someone will help me asap.
here is my code.
Private Sub AdminPage_Load(sender As Object, e As EventArgs) Handles Me.Load
BookPanel.Height = 0
End Sub
Private Sub Book_MouseEnter(sender As Object, e As EventArgs) Handles Book.MouseEnter
Do While BookPanel.Height < 210
BookPanel.Height += 1
Loop
End Sub
Private Sub Book_MouseLeave(sender As Object, e As EventArgs) Handles Book.MouseLeave
Do While BookPanel.Height > 0
BookPanel.Height -= 1
Loop
End Sub
|
|
|
|
|
Using VWD2008 and Office 2010 - I am trying to create an excel object.
When run through VWD, a spreadsheet is created, formatted and saved fine. When the code is compiled (and run on the same machine), the create object or new Excel.Application falls over.
1) as object using Microsoft.Office.Core dll:
Dim xlApp As Object = CreateObject("Excel.Application")
2) As Excel application using Microsoft.Office.Interop.Excel dll
Dim xlApp As Application = New Application
|
|
|
|
|
Are we supposed to guess the exception that's thrown when the code "falls over"?
Provide the full details of the exception, the line of code where it's thrown, and any relevant parts of the surrounding code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The exception message was 'Cannot create ActiveX component.' I have updated the DCOM config permissions for Excel Application and restarted IIS, but still no joy
The following is all of the code behind (this page is cut down from a page that gets mountains of data - just to test the create & save excel part )
Imports CommonFunctions
Imports Microsoft.VisualBasic
Imports Microsoft.Office.Core
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Partial Class FEMain_ContractAdmin_TestExcel2
Inherits System.Web.UI.Page
Dim objCF As New CommonFunctions
Protected Sub btnKPI_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnKPI.Click
Dim xlApp As Object
Try
xlApp = CreateObject("Excel.Application")
Catch ex As Exception
objCF.logError(System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.Url.AbsolutePath) & " :: " & System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message)
Exit Sub
End Try
Dim xlWorkBook As Object
Dim xlWorksheet As Object
Dim misValue As Object = System.Reflection.Missing.Value
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorksheet = xlWorkBook.Sheets("Sheet1")
xlWorksheet.Cells(1, 1) = "Test 123456"
Dim strSavePath As String
Dim strFilename As String
Dim strFullPath As String
strSavePath = AppDomain.CurrentDomain.BaseDirectory & "Documents\KPI\Concerns\"
'create kpi concern directory
If (Not Directory.Exists(strSavePath)) Then
Directory.CreateDirectory(strSavePath)
End If
strFilename = "Test_" & CStr(Date.Now.Year) & objCF.addZeros(CStr(Date.Now.Month), 2) & objCF.addZeros(CStr(Date.Now.Day), 2) & "_" & objCF.addZeros(CStr(Date.Now.Hour), 2) & objCF.addZeros(CStr(Date.Now.Minute), 2) & objCF.addZeros(CStr(Date.Now.Second), 2) & objCF.addZeros(CStr(Date.Now.Millisecond), 3) & ".xlsx"
strFullPath = strSavePath & strFilename
'save and close
xlWorkBook.SaveAs(strSavePath & strFilename)
xlWorkBook.Close(True, misValue, misValue)
xlApp.Quit()
'release COM objects
Call objCF.releaseObject(xlWorksheet)
Call objCF.releaseObject(xlWorkBook)
Call objCF.releaseObject(xlApp)
'show the hyperlink to the excel file
hypKPI.Visible = True
hypKPI.NavigateUrl = "~\Documents\KPI\Concerns\" & strFilename
End Sub
End Class
|
|
|
|
|
You should read the following Microsoft knowledgebase article:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
It documents the various hoops that you'll have to jump through to stand any chance of getting Office Interop working in ASP.NET; however, there is no guarantee that you'll be able to get it working, or that it won't stop working at some random point in the future.
There are various ways to read and create Excel spreadsheets on the server without using Office interop. For example:
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Also, if you're on a 64-bit OS, check your AppPool settings to make sure you've selected "Enable 32-bit Applications". A 64-bit AppPool won't be able to create and use an instance of a 32-bit COM component.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Why are you defining everything as Object? That's actually going to hurt you, not help you. You loe all type safety when you do that.
|
|
|
|
|
DAH_bham wrote: strFilename = "Test_" & CStr(Date.Now.Year) & objCF.addZeros(CStr(Date.Now.Month), 2) & objCF.addZeros(CStr(Date.Now.Day), 2) & "_" & objCF.addZeros(CStr(Date.Now.Hour), 2) & objCF.addZeros(CStr(Date.Now.Minute), 2) & objCF.addZeros(CStr(Date.Now.Second), 2) & objCF.addZeros(CStr(Date.Now.Millisecond), 3) & ".xlsx"
You really need to look at Custom Date and Time Format Strings[^] and the String.Format method[^]:
strFilename = String.Format("Test_{0:yyyyMMdd_HHmmssfff}.xlsx", Date.Now)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I tried Excel Package (OpenOfficeXML) instead of Office COM dlls and it worked fine for my needs -
thanks for your help.
|
|
|
|
|
Oh, and one more thing. The code is never interpreted when running in the debugger. It's always compiled into an .executable and launched.
|
|
|
|
|
I am using the progress bar supplied with VB 2013 - everything works as it should except that the "flying left to right highlight animation" does not work - the moving bar is just the flat solid colour. On the designer I see the "highlight flying" effect but not when I run or test the .exe file! I have searched everywhere for any clues and so far hit a blank wall. Is there some property I should be setting on the progress bar to achieve this? Any clue would be appreciated.
All the best and TIA.
HotBlue
|
|
|
|
|
What operating system?
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Sorry - I should have included this. I used Win 7, 8.1 and 10 with Framework 4.0 - all gave the same results, flat colour and no highlight fly by.
|
|
|
|
|
How are you updating the progress bar?
|
|
|
|
|
The bar updates when an action has completed within a loop thus:
; Initialise
frm_Splash.bar_Loading.Width = 390
ffrm_Splash.bar_Loading.Maximum = 39
rm_Splash.bar_Loading.Style = ProgressBarStyle.Continuous
frm_Splash.bar_Loading.Enabled = True
frm_Splash.bar_Loading.Visible = True
frm_Splash.bar_Loading.Value = 0
ActionLevel = 0
; Working loop.
For I = 0 to 39
; ... working code here.
ActionLevel += 1 ; Advance Progress Bar.
frm_Splash.bar_Loading.Value = ActionLevel
Application.DoEvents()
Next
The bar progresses normally but no highlight "flyby" animation.
|
|
|
|
|
|