|
I want to upgrade one of the vb project to vb.net, but some method that is not support in vb.net, did anyone can help me?? The main problem is the picture.Point and picture.PSet not support in vb.net...
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
Dim x, y As Integer
Dim c, d As Integer
Dim p1, p2 As Integer
Dim B1, R1, G1 As Integer
Dim B2, R2, G2 As Integer
Dim t As Integer
Dim r As Short
Dim per As Integer
Dim msg As String
Picture3.Refresh()
t = CInt(Text1.Text)
Form1.DefInstance.Text = "Image Mapper - Mapping"
Do Until y > VB6.PixelsToTwipsY(Picture1.Height) Or y > VB6.PixelsToTwipsY(Picture2.Height)
p1 = Picture1.Point(x, y)
p2 = Picture2.Point(x, y)
RGB_get(p1, R1, B1, G1)
RGB_get(p2, R2, B2, G2)
Diff(r, R1, R2, B1, B2, G1, G2, t)
If r = 0 Then
d = d + 1
Picture3.PSet (x, y), System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue)
Else
Picture3.PSet (x, y), System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red)
End If
c = c + 1
x = x + 15
If x > VB6.PixelsToTwipsX(Picture1.Width) Or x > VB6.PixelsToTwipsX(Picture2.Width) Then x = 0 : y = y + 15
Loop
per = 100 - ((d / c) * 100)
msg = msg & "RESULTS" & vbCrLf
msg = msg & "=============" & vbCrLf
msg = msg & "Total Pixles Scanned: " & c & vbCrLf
msg = msg & "Total Different Pixles: " & d & vbCrLf
msg = msg & "Total Similar Pixles: " & (c - d) & vbCrLf
msg = msg & "Percent Similar: " & per & " %" & vbCrLf
If per > 75 Then
msg = msg & "The computer has judged this as: SIMILAR"
Else
msg = msg & "The computer has judged this as: DIFFERENT"
End If
Form1.DefInstance.Text = "Image Mapper - Mapped"
MsgBox(msg, CDbl(0 & 32), "Scan Complete:")
End Sub
End Class
ption Strict Off
Option Explicit On
Module RGBCov
Structure COLORRGB
Dim red As Integer
Dim green As Integer
Dim blue As Integer
End Structure
Function RGB_get(ByVal CVal As Integer, ByRef r As Integer, ByRef B As Integer, ByRef G As Integer) As COLORRGB
G = Int(CVal / 65536)
B = Int((CVal - (65536 * G)) / 256)
r = CVal - (65536 * G + 256 * B)
End Function
Function Diff(ByRef Result As Short, ByRef R1 As Integer, ByRef R2 As Integer, ByRef B1 As Integer, ByRef B2 As Integer, ByRef G1 As Integer, ByRef G2 As Integer, ByRef Tol As Integer) As Object
If R1 > R2 + Tol Or B1 > B2 + Tol Or G1 > G2 + Tol Or R1 < R2 - Tol Or B1 < B2 - Tol Or G1 < G2 - Tol Then
Result = 0 'False
Else
Result = 1 'True
End If
End Function
End Module
|
|
|
|
|
Hello.. i wrote excel automation using vc++ 6.0
I had no problem..
now I'm converting all the c++ code into vb.net code and i am encountering problems
whenever I call any function/ method of Excel.Sheets I got following message
<br />
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in PrintMSOF.exe<br />
<br />
Additional information: Exception from HRESULT: 0x800A03EC.
here How I open the file and get all sheets to printpreview
I also tried
shets = wBook.Worksheets to get the WorkSheets as I did in c++ but error toooo
<br />
Dim excelApp As Excel.Application<br />
Dim wBooks As Excel.Workbooks<br />
Dim wBook As Excel.Workbook<br />
Dim sheets As Excel.Sheets<br />
Dim shets As Excel.WorkSheets<br />
excelApp = CreateObject("Excel.Application")<br />
excelApp.Visible = True<br />
excelApp.UserControl = True<br />
wBooks = excelApp.Workbooks()<br />
wBook = wBooks.Open(filename)<br />
sheets = wBook.Worksheets<br />
sheets.Select() 'error error error error<br />
|
|
|
|
|
I'm trying to expand the datagrid's functionality to meet my needs. But I'm also fairly new to .NET (I've done alot of ASP/VB/Perl/PHP/PB, etc programming, just not .NET)
Anyhow, what I'd like to be able to do is make my own control, using the datagrid as the foundation. Incorporating different column controls (namely drop downs), and some other standard features like sorting/filtering, etc.
My biggest concern, beyond how to use a combo box for a field, is how I can bind that combo box, to the proper lookup table for the id that should be stored in that field.
Meaning.
I fill my data grid with data from a query something like:
"SELECT FirstName, LastName, CityID FROM People"
How I can make the 3rd column a drop down combo box, bind it's source to be "SELECT CityId, Name FROM Cities" and have it show just the Cities.Name, but when I save the modifications to the grid, it stores the Cities.CityID in the People table.
Does that make sense?
While alot of that 'could' be done in code I'd like to have some form of design time editor for this extended datagrid control. A way to give the developer a simpler interface to allow all of this.
I'm sure it's possible, but I don't have a clue where to begin.
Thanks for the help,
--Gibbs
|
|
|
|
|
I have just developed a VB application that will be using Outlook to send email to some other people as part of a process.
I have developed my application on a PC that has Outlook2000 which has 9.0 Object library installed with it. However, this application is required to run on different PCs that have different versions of Outlook. This means that it may not see some objects in the library depending on which version of Outlook is installed.
How can I overcome this problem in my code before it actually goes live?
Thanks for any help
|
|
|
|
|
VB6 or .NET?
What is your deployment method (PC install, server install, web, etc.)?
|
|
|
|
|
Built using VB6 and will be deployed through PC Install on users systems. Users are not on a network. They require the system to send returns to the main office.
|
|
|
|
|
If you use the "Package and Deployment Wizard" that comes with Visual Basic to build you setup program, the Microsoft Outlook 9.0 Object Library (MSOUTL9.OLB) should be included in the installation. Because Microsoft generally names each version of there libraries and dlls differently, you shouldn't have any trouble breaking any other application by installing MSOUTL9.OLB. Additionally, you can specify that the MSOUTL9.OLB file be installed in your application directory as opposed to the Windows System directory. Disclaimer...I have not tested this...so you should obviously test it first. Good luck.
|
|
|
|
|
Hi Friends,
i have written code in VB .net for sending mail using MAPI.
I am facing two problems.
1. The mail does go, but when i give an attachment, it gives the following exception.
System.Runtime.InteropServices.COMException (0x800A7D02): Unspecified Failure has occurred
at MSMAPI.MAPIMessagesClass.Send(Object vDialog)
at ProcTryMail.tryMail.Pr_SendMail() in D:\Projects\Ems\Backup_Nov17OutSeq\ProcTryMail\tryMail.vb:line 30
MSDN says this occurs when multiple attachments are put.
2. when i finally send mail, i get an outlook warning saying:
A program is trying to automatically send e-mail on your behalf. Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No".
The code is given below.
Public Class tryMail
Private objMapiSession As MSMAPI.MAPISession
Private objMapiMsgs As MSMAPI.MAPIMessages
Private objDebug As EMSDebug.cDebug
Public Sub Pr_SendMail()
Try
objMapiSession = New MSMAPI.MAPISession()
objMapiMsgs = New MSMAPI.MAPIMessages()
objMapiSession.LogonUI = False
objMapiSession.SignOn()
objMapiMsgs.SessionID = objMapiSession.SessionID
objMapiMsgs.Compose()
objMapiMsgs.RecipDisplayName = "-- give a mail id here --"
objMapiMsgs.MsgSubject = "From .NET MAPI"
objMapiMsgs.AttachmentPathName = "-- give a filepath here --"
objMapiMsgs.Send(False)
objMapiSession.SignOff()
objMapiSession = Nothing
objMapiMsgs = Nothing
Catch
End Try
End Sub
End Class
thanks
Alex
|
|
|
|
|
The second problem is caused by a security setting in Outlook that Microsoft put in after the outbreak of viruses that emailed themselves to everyone in your Outlook address book. To turn it off, open Outlook (Express) and pick Options from the Tools menu, then click the Security tab, then uncheck "Warn me when applications try to send mail as me."
There is no method of getting around this programatically, for obvious reasons...
RageInTheMachine9532
|
|
|
|
|
Problem: I need to make a unattended dial-up connection to a pc. (normal phone line) login start a FTP session to retrieve and send some files, logoff and disconnect.
Then start allover again with a different pc.
Does anybody know how to do this in vb.net
Thanks for every tip.
Ferry
|
|
|
|
|
Calling a Dialup connection
|
|
|
|
|
I am developing an ActiveX in VB6 control to be used in a html page. The control is downloaded and installed from the web (there is a codebase tag in html). The control then calls servlets, the servlet address is a parameter in html.
I wold like to avoid an url parameter in the object tag. Can the control in any way retrieve the url from the browsers session?
|
|
|
|
|
I have a windows apllication ,I want to connect to the SQL Server database which is in the web server at USA .Can any one please tell me how to connect the database using VB.NET.
Any response with source code will be highly appreciated.
Thanks in advance
|
|
|
|
|
Hi Friends,
when i call a MSMAPI object from a standalone exe in VB .NET, i am able to send a mail. But when i spawn this exe as a process from a windows service, i get an error message while signing on using the MAPI session SignOn() method. I tried using windows service logon as both local system and using my NT logon too. The error message thrown is
System.Runtime.InteropServices.COMException (0x800A7D1A): Not supported
at MSMAPI.MAPISessionClass.SignOn()
at ProcTryMail.tryMail.Pr_SendMail() in D:\Projects\Ems\Backup_Nov17OutSeq\ProcTryMail\tryMail.vb:line 20
My feeling was that some security access is required.
The code i have used is:
Public Class tryMail
Private objMapiSession As MSMAPI.MAPISession
Private objMapiMsgs As MSMAPI.MAPIMessages
Private i As Boolean
Public Sub Pr_SendMail()
Try
objMapiSession = New MSMAPI.MAPISession()
objMapiMsgs = New MSMAPI.MAPIMessages()
objMapiSession.SignOn()
objMapiMsgs.SessionID = objMapiSession.SessionID
objMapiMsgs.Compose()
objMapiMsgs.RecipDisplayName = "--give some mail id here--"
objMapiMsgs.MsgSubject = "From .NET MAPI"
objMapiMsgs.Send()
objMapiSession.SignOff()
Catch
End Try
End Sub
End class
Will be grateful if anyone of u is able to find out the problem.
Thanks
Alex
|
|
|
|
|
OK. When you run the project as a standalone .EXE, do you get a dialog box when you execute the SignOn method? You should, because that is the default behavior for the Session control. Problem is, as a service, there is no desktop, and therefor no user interface to display a dialog box.
You might want to try setting the LogonUI property of the control to FALSE and setting the UserName and Password properties before you call SignOn.
RageInTheMachine9532
|
|
|
|
|
Thanx RageInTheMachine9532. Setting the LogonUI property to false solves the problem.
|
|
|
|
|
Hi folks, my problem is too dificult for me to parse. I need to translate this code snipet to VB.NET :
public RECT SetTVItemRECTHandle(IntPtr hItem,RECT RC){
RECT rc1=new RECT();
unsafe
{
*(IntPtr*)&rc1 = hItem;
}
return rc1;
}
The part that bugs me and got me lost is the '*(IntPtr*)&rc1 = hItem;' thing. For now I'm relying on a C# function in a DLL to accomplish the work but I'd like to know if it can be done in VB so that I can discard this extra dependency from my solution. For your information, this function is used to retrieve the rectangle for a list view column header for owner drawing.
Thanks
The_Warlord
|
|
|
|
|
I could be wrong, but it looks like rc1 is being declared as a RECT class and a new object is being created. Then it changes the address of the rc1 class to point to a segment of memory that hItem is pointing to. As far as I know, VB doesn't support this.
RageInTheMachine9532
|
|
|
|
|
Could you post the code that leads up to this? I'm looking for the code that generates the 'hItem' and 'RC' parameters so I can play with it and see what the possiblities are.
Thanks,
RageInTheMachine9532
|
|
|
|
|
The context is custom draw a treeview, in particular a tree node. Here is the WndProc from my Component:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim intLeft As Integer
Dim RC As RECT
Dim RC2 As CantDoInVBButInCSharp.RECT
Dim RCF As RectangleF
Dim nm1 As NMHDR
Dim nmcd As NMTVCUSTOMDRAW
Dim hNode As IntPtr
Dim PU As New CantDoInVBButInCSharp.PointerUtils()
If m.Msg = ReflectedMessages.OCM_NOTIFY Then
nm1 = m.GetLParam((nm1.GetType))
If nm1.code = NotificationMessages.NM_CUSTOMDRAW Then
nmcd = m.GetLParam(nmcd.GetType)
If nmcd.nmcd.dwDrawStage = CustomDrawDrawStateFlags.CDDS_PREPAINT Then
m.Result = New System.IntPtr(CustomDrawReturnFlags.CDRF_NOTIFYITEMDRAW)
End If
If nmcd.nmcd.dwDrawStage = CustomDrawDrawStateFlags.CDDS_ITEMPREPAINT Then
hNode = New IntPtr(CInt(nmcd.nmcd.dwItemSpec.ToString))
RC2 = PU.SetTVItemRECTHandle(hNode, Nothing)
SendMessage2(Handle, TreeViewMessages.TVM_GETITEMRECT, 1, RC2)
mvarTextBrush = New LinearGradientBrush(New Rectangle(RC2.left, RC2.top, RC2.right - RC2.left, RC2.bottom - RC2.top), mvarTextGradientColor1, mvarTextGradientColor2, mvarGradientMode)
Graphics.FromHdc(nmcd.nmcd.hdc).DrawString("Test", Me.Font, mvarTextBrush, New RectangleF(RC2.left, RC2.top, RC2.right - RC2.left, RC2.bottom - RC2.top))
hClickedItem = IntPtr.Zero
m.Result = New System.IntPtr(CustomDrawReturnFlags.CDRF_SKIPDEFAULT)
End If
If nmcd.nmcd.dwDrawStage = CustomDrawDrawStateFlags.CDDS_ITEMPOSTPAINT Then
End If
ElseIf nm1.code = TreeViewNotifications.TVN_ITEMEXPANDEDW Then
Me.Invalidate()
m.Result = IntPtr.Zero
ElseIf nm1.code = TreeViewNotifications.TVN_ITEMEXPANDINGW Then
Me.Invalidate()
m.Result = IntPtr.Zero
ElseIf nm1.code = TreeViewNotifications.TVN_SELCHANGINGW Then
Me.Invalidate()
m.Result = IntPtr.Zero
End If
ElseIf m.Msg = Msg.WM_ERASEBKGND Then
'If Not (hClickedItem.Equals(IntPtr.Zero)) Then
MyBase.CreateGraphics.FillRectangle(mvarBackBrush, ClientRectangle)
ControlPaint.DrawBorder3D(MyBase.CreateGraphics, ClientRectangle, mvarBorderStyle)
'End If
m.Result = New System.IntPtr(CustomDrawReturnFlags.CDRF_SKIPDEFAULT)
ElseIf m.Msg = Msg.WM_SIZING Then
mvarBackBrush = New LinearGradientBrush(ClientRectangle, mvarGradientColor1, mvarGradientColor2, mvarGradientMode)
ElseIf m.Msg = ReflectedMessages.OCM_VSCROLL Then
'm.Result = IntPtr.Zero
Else
MyBase.WndProc(m)
End If
End Sub
Thank you for your time.
The_Warlord
|
|
|
|
|
Sorry, but I haven't been able to get a solution to this problem to work. I'm still working on it, but It's been slow since I've been moving my girlfriend! 8)
RageInTheMachine9532
|
|
|
|
|
Has anyone out there created an application using "dynamic" function calls. By dynamic I mean that you can instanciate an ActiveX object using the CreateObject() function and then make a call to a function using another variable. Maybe the following example will illustrate my questions.
Let's say there is an ActiveX DLL called TestDll, that contains a class called Test, which has a method called GetText() and it returns a String. In the following code I want to access the GetText method "dynamically". See below...
...
Dim obj as Object
Dim sFunctionName as String
Dim sResult as String
' Create my Test object
Set obj = CreateObject("TestDll.Test")
' Set the name of the function that I want to call "dyanmically"
sFunctionName = "GetText"
'Now dynamically call GetText
'The following line obviously doesn't work and what I'm trying to do is make a call to obj.GetText()
sResult = obj.[sFunctionName]
...
If anyone has any constructive ideas, I'd be appreciated.
|
|
|
|
|
|
How about using the CallByName function?
|
|
|
|
|
The CallByName function would do this. But I have to ask why you would want to go through such a hassle? There is no type checking of data being passed to the function or for the type of call your making. On top of that, using this function does not support return values from functions using ByRef passing and there is also a performance penalty.
RageInTheMachine9532
|
|
|
|
|