| Can VC++ 6.0 build 64-bit apps? |
|
 |
Index ‹ Visual Studio ‹ Visual Studio C++
|
- Previous
- 1
- Visual Basic [VB] >> Dynamically adding and iterating through webcontrolsHi everyone,
I created a page which contains a two-column table. The first column has a
bunch of labels, and the second a bunch of textboxes. Here's the code:
======================================================
Protected WithEvents Container As System.Web.UI.WebControls.PlaceHolder
Private Sub ConstructEditTable()
Container.Controls.Add(New LiteralControl("<table>" & vbNewLine))
Dim i As Integer
For i = 0 To rows
With Container.Controls
.Add(New LiteralControl("<tr>" & vbNewLine))
'Label column
.Add(New LiteralControl("<td>" & vbNewLine))
label = New Label
label.ID = "lbl" & i.ToString
label.Text = i.ToString
label.EnableViewState = True
.Add(label)
.Add(New LiteralControl("</td>" & vbNewLine))
'Textbox column
.Add(New LiteralControl("<td>" & vbNewLine))
txtTest = New TextBox
txtTest.ID = "txt" & i.ToString
txtTest.Width = Unit.Pixel(50)
txtTest.EnableViewState = True
.Add(txtTest)
.Add(New LiteralControl("</td>" & vbNewLine))
.Add(New LiteralControl("</tr>" & vbNewLine))
End With
Next
Container.Controls.Add(New LiteralControl("</table>" & vbNewLine))
End Sub
==========================================================
The problem I have is accessing the content of the textboxes after postback.
How do I iterate through the controls in Container? Basically, after
PostBack, I would like to display the same table but with labels in the
second column, instead of textboxes. These labels would display the content
of the textboxes entered prior to PostBack.
Any ideas anyone? Any suggestions would be greatly appreciated.
Cheers,
Dany.
- 2
- MFC >> strange issue with drag and drop target windowhi there
i am implementing drag n drop in my app using the COleDataSource/
COleDropSource/COleDropTarget classes
everything is going well, but there is one strange thing going on
one of my target windows is a plain ole CWnd-derived window, which has
some child buttons created on it dynamically - i register a
COleDropTarget object for the CWnd-derived parent window, but *not*
for any of the child button windows
when i try to drag onto this window, the COleDropTarget instance that
was registered for the window only gets its OnDragEnter/OnDragOver/
OnDragLeave/OnDrop methods called when the mouse is over one of the
*child* buttons, and never when it is moving over open space within
the window
i check window handles in the COleDropTarget handlers, and the window
passed to these methods has the same handle as my main CWnd-derived
window, *not* the handle of the child button, so that makes sense
also, when i create *no* child buttons on the CWnd-derived window, the
drop handlers don;t get called *at all*
so why oh why shouldn't the COleDropTarget object be called when the
cursor is *anywhere* the registred window?
its driving me nuts
any help will be greatly appreciated
regards
bhu
- 3
- MFC >> Resource leakThis is a multi-part message in MIME format.
------=_NextPart_000_0022_01C39EFE.09B31940
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
What is wrong with this code?
CodeSnitch of Entrek (utility that allows profiling WinCE) emphasise the =
red line as a resourse leak.=20
Assuming that in my test application there is no use of the m_Brush, =
this leak is really weird.
Somebody can explane it?
CPOEApp::CPOEApp(LPCTSTR lpszAppName): CWinApp(lpszAppName)
{
m_Brush.CreateSolidBrush(TOP_LABEL_COLOR); //resource leak
}
CPOEApp::~CPOEApp()
{
m_Brush.DeleteObject();
}
Stas K
------=_NextPart_000_0022_01C39EFE.09B31940
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1264" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY dir=3Dltr>
<DIV>
<P><FONT face=3DArial size=3D2>What is wrong with this code?</FONT></P>
<P><FONT face=3DArial size=3D2>CodeSnitch of Entrek (utility that allows =
profiling=20
WinCE) emphasise the red line as a resourse leak. </FONT></P>
<P><FONT face=3DArial size=3D2>Assuming that in my test application =
there is no use=20
of the m_Brush, this leak is really weird.</FONT></P>
<P><FONT face=3DArial size=3D2>Somebody can explane it?</FONT></P>
<P><FONT face=3DArial size=3D2>CPOEApp::CPOEApp(LPCTSTR lpszAppName):=20
CWinApp(lpszAppName)</FONT></P>
<P><FONT face=3DArial size=3D2>{</FONT></P>
<P><FONT face=3DArial size=3D2> <FONT=20
color=3D#ff0000><STRONG>m_Brush.CreateSolidBrush(TOP_LABEL_COLOR); =
//resource=20
leak</STRONG></FONT></FONT></P>
<P><FONT face=3DArial size=3D2>}</FONT></P>
<P><FONT face=3DArial size=3D2>CPOEApp::~CPOEApp()</FONT></P>
<P><FONT face=3DArial size=3D2>{</FONT></P>
<P><FONT face=3DArial size=3D2> =
m_Brush.DeleteObject();</FONT></P>
<P><FONT face=3DArial size=3D2>}</FONT></P>
<P><FONT face=3DArial size=3D2>Stas K</FONT></P></DIV></BODY></HTML>
------=_NextPart_000_0022_01C39EFE.09B31940--
- 4
- Visual Basic >> Error while opening a recordsetHi,
I am getting error "Multiple step OLE DB operation generatied errors. Check
each status value" while opening a recordset with records of nearly 4300000.
The records are unique in the table.
I am using the below coding to open the recordset.
With Recordset
.CursorLocation = adUseServer
.Open SQL, Cn, adOpenKeyset, adLockReadOnly
End With
Please can any one help me in finding what's the issue that causes the
error.
Thanks
Valli
- 5
- Visual Basic [VB] >> Trying to create a copy of a .NET dllHello,
I'm trying to make a copy of a .NET dll for testing purposes.
I've changed the target of my dll from MyDLL.dll to MyDLLTest.dll. In
the AssemblyInfo.vb, I've changed the from:
<Assembly: AssemblyDescription("My DLL")>
to:
<Assembly: AssemblyDescription("My DLL Test")>
I've then copied the MyDLLTest.dll to the same directory as a VB6 test
harness that I've built and run regasm MyDLLTest.dll /tlb:MyDLLTest.tlb
to create
the type library.
Next, I go to add a reference in my VB6 test harness
and browse to the .tlb file that's in the same directory. I click add
and in the references in my VB6 project I see "My DLL" instead of "My
DLL Test".
Please note that the MyDLL.dll that I'm basing the
MyDLLTest.dll from is registered in COM+. I'm wondering if I need to
change the guid in the AssemblyInfo.vb in order to get "My DLL Test" to
show up in the references description in my VB6 project. I've added
some additional debugging information to to MyDLLTest.dll that's not in
MyDLL.dll.
I want to be able to move this VB6 exe together with MyDLLTest.dll to
another machine that also has MyDLL.dll registered in COM+. I'm
figuring that this way I can see what's going on in MyDLL.dll without
disturbing the existing MyDLL.dll that's registered in COM+.
Thanks,
Eric
- 6
- VB Scripts >> help neededIm writing an bat file to rename an file with a new name, and i need to
get the ERRORLEVEL value from this bat file into an VBScript.
I m always getting an zero errorlevel when i run the bat file from the
script
My code is below...
BAT FILE
---------------------------------
@echo off
:: do something that sets errorlevel 1
REN fil fils
echo %ERRORLEVEL%
(this would return an 1 when run from dos prompt)
VBScript
-------------------------------------
Dim fso, wShell, i
Set wShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
i = wShell.Run ("C:\test1.bat", 1, True)
WScript.Echo i
(This should return 1, but returns only 0)
Y is this happening, is there anything wrong with my logic
Rajesh.N
- 7
- Visual Basic [VB] >> Need a palette expert hereBelow is a small but complete program that appears to show you
can't retrive a Palette from the clipboard.
This is true whether the palette is placed on the clipboard by Photoshop or
Photoshop or by the below program
It lets you place a palette from a file or from a program on the clipboard
and allows you to retrieve one from the clipboard. But you'll find the
retrieved one is always "Nothing"
I'd appreciate comments
Imports System.Drawing.Imaging
Public Class Form1
Inherits System.Windows.Forms.Form
Private WithEvents button1 As System.Windows.Forms.Button
Private WithEvents button2 As System.Windows.Forms.Button
Private WithEvents button3 As System.Windows.Forms.Button
Private components As System.ComponentModel.IContainer
Private cp As ColorPalette
Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Public Sub New()
InitializeComponent()
End Sub 'New
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 'Dispose
#Region "Windows Form Designer generated code"
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.button1 = New System.Windows.Forms.Button
Me.button2 = New System.Windows.Forms.Button
Me.button3 = New System.Windows.Forms.Button
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.SuspendLayout()
'
'button1
'
Me.button1.Location = New System.Drawing.Point(186, 124)
Me.button1.Name = "button1"
Me.button1.Size = New System.Drawing.Size(130, 24)
Me.button1.TabIndex = 2
Me.button1.Text = "Copy File Palette"
Me.ToolTip1.SetToolTip(Me.button1, "Copy Palette from a GIF file to the
clipboard")
'
'button2
'
Me.button2.Location = New System.Drawing.Point(13, 124)
Me.button2.Name = "button2"
Me.button2.Size = New System.Drawing.Size(156, 24)
Me.button2.TabIndex = 2
Me.button2.Text = "Retrieve Clipboard Palette"
Me.ToolTip1.SetToolTip(Me.button2, "Retrieve a palette from the clipboard")
'
'button3
'
Me.button3.Location = New System.Drawing.Point(88, 167)
Me.button3.Name = "button3"
Me.button3.Size = New System.Drawing.Size(130, 24)
Me.button3.TabIndex = 2
Me.button3.Text = "Exit"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(12, 24)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(304, 47)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = "Palette can be placed on clipboard by using the 'Save
Palette"" button or by some " & _
"external program such as Photoshop"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(13, 85)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(302, 20)
Me.TextBox2.TabIndex = 4
'
'Timer1
'
Me.Timer1.Enabled = True
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(328, 204)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.button1)
Me.Controls.Add(Me.button2)
Me.Controls.Add(Me.button3)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub 'InitializeComponent
#End Region
<STAThread()> Shared Sub Main()
Application.Run(New Form1)
End Sub 'Main
Private Sub button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles button1.Click
Dim dlg As New OpenFileDialog
dlg.Filter = "GIF files|*.GIF"
If dlg.ShowDialog() = DialogResult.OK Then
Dim zz As Image = Image.FromFile(dlg.FileName)
Dim DataO As New DataObject
DataO.SetData(DataFormats.Bitmap, False, CType(zz, Bitmap))
DataO.SetData(DataFormats.Palette.ToString, False, zz.Palette)
Clipboard.SetDataObject(DataO, False)
End If
End Sub 'button1_Click
Private Sub button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles button2.Click
Dim DataO As DataObject = CType(Clipboard.GetDataObject(), DataObject)
If DataO.GetDataPresent(DataFormats.Palette, False) Then
cp = CType(DataO.GetData(DataFormats.Palette), ColorPalette)
If cp Is Nothing Then
MessageBox.Show("Contains palette that is Nothing")
Else
MessageBox.Show(cp.ToString)
End If
Else
MessageBox.Show("No Palette on Clipboard")
End If
End Sub 'button2_Click
Private Sub button3_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles button3.Click
Application.Exit()
End Sub 'button3_Click
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Timer1.Tick
Dim DataO As DataObject = CType(Clipboard.GetDataObject(), DataObject)
If DataO.GetDataPresent(DataFormats.Palette, False) Then
Dim cp As ColorPalette = CType(DataO.GetData(DataFormats.Palette),
ColorPalette)
TextBox2.Text = "There is a Palette on the Clipboard"
Else
TextBox2.Text = "The Clipboard does not contain a Palette"
End If
End Sub
End Class 'Form1
- 8
- 9
- 10
- MFC >> ModifyMenuI want to modify the menus, if the user has selected a new languages.
With the Popup- menus in the menu-bar I can do this with
ModifyMenu(..,<level>,MF_BY_POSITION,<level>,<new string>).
In the submenus I can do this with
ModifyMenu(..,<id>,MF_BY_COMMAND,<id>,<new string>).
All this works fine. Sometimes I have also a POPUP for a submenu
within a submenu. In this case a have no identifier, which
with I can change the text. And I cannot use the "MF_BY_POSITION", because
this
works only for menus, but not for submenus.
Who can help me?
Andreas
- 11
- Visual Basic >> Program Version NumberIn Project Properties in Version Number I see: Major 12, Minor 1, Revision
10.
When I compile my project and via EXE's properties I see Version 12.1.0.10
Where 0 does come from?
Is there any place in VB environment to control that third place in version
number? Now it's always 0.
Thank you
vovan
- 12
- MFC >> resource-only DLL and LNK2019 error!!Hi,
i'm developing a resource-only DLL, using /NOENTRY option the linker returns:
error LNK2019: unresolved external symbol _main referenced in function
_mainCRTStartup
Any help!?
Thanks
Ale
- 13
- Visual Basic [VB] >> Run a sub from within a tread?I'm a newbie to threads. I can run
"comboProfiles_SelectedIndexChanged(sender, e)" from any normal sub in my
project however if I run this from within a new thread I've started it
doesn't like "sender" or "e". I know sending info from within a thread is
different but what I'm doing should be simple so if someone can help me out
I sure would appreciate it.
Thanks Much,
Justin
- 14
- Visual Basic [VB] >> Application Migration from VB6 to .NETI have an application my partner wrote that would allow an autoresponse to any
Mapi compliant email that apparently in .Net won't, can someone assist me with
fixing this?
Here is the code:
Utilities Module:
Option Explicit
Option Base 1
Public StrSQL As String
Public objSession As MAPI.Session
Public objNewMessage As Message
Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Global Const REG_SZ As Long = 1
Global Const REG_DWORD As Long = 4
Global Const HKEY_CURRENT_USER = &H80000001
Global Const ERROR_NONE = 0
Global Const ERROR_BADDB = 1
Global Const ERROR_BADKEY = 2
Global Const ERROR_CANTOPEN = 3
Global Const ERROR_CANTREAD = 4
Global Const ERROR_CANTWRITE = 5
Global Const ERROR_OUTOFMEMORY = 6
Global Const ERROR_INVALID_PARAMETER = 7
Global Const ERROR_ACCESS_DENIED = 8
Global Const ERROR_INVALID_PARAMETERS = 87
Global Const ERROR_NO_MORE_ITEMS = 259
Global Const KEY_ALL_ACCESS = &H3F
Global Const REG_OPTION_NON_VOLATILE = 0
Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef
lpVersionInformation As OSVERSIONINFO) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As
Long
Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA"
(ByVal hKey As Long, _
ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As
Long, phkResult As Long) As Long
Public Declare Function RegQueryValueExString Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, _
ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long,
ByVal lpData As String, lpcbData As Long) As Long
Public Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, _
ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long,
lpData As Long, lpcbData As Long) As Long
Public Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, _
ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long,
ByVal lpData As Long, lpcbData As Long) As Long
Public Function QueryValue(sKeyName As String, sValueName As String)
Dim lRetVal As Long 'result of the API functions
Dim hKey As Long 'handle of opened key
Dim vValue As Variant 'setting of queried value
lRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, KEY_ALL_ACCESS,
hKey)
lRetVal = QueryValueEx(hKey, sValueName, vValue)
QueryValue = vValue
RegCloseKey (hKey)
End Function
Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As String, vValue
As Variant) As Long
Dim cch As Long
Dim lrc As Long
Dim lType As Long
Dim lValue As Long
Dim sValue As String
On Error GoTo QueryValueExError
' Determine the size and type of data to be read
lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch)
If lrc <> ERROR_NONE Then Error 5
Select Case lType
' For strings
Case REG_SZ:
sValue = String(cch, 0)
lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, sValue, cch)
If lrc = ERROR_NONE Then
vValue = Left$(sValue, cch)
Else
vValue = Empty
End If ' For DWORDS
Case REG_DWORD:
lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, lValue, cch)
If lrc = ERROR_NONE Then vValue = lValue
Case Else
'all other data types not supported
lrc = -1
End Select
QueryValueExExit:
QueryValueEx = lrc
Exit Function
QueryValueExError:
Resume QueryValueExExit
End Function
Public Sub SendMail(Recip As String, Subj As String, Body As String)
Dim objOutBox As Folder
Dim objNewMessage As Message
Dim objRecipients As Recipients
Dim objOneRecip As Recipient
'StartMessagingAndLogon
objSession.Logon frmLogin.txtUserName, frmLogin.txtPassword, True, True
Set objOutBox = objSession.Outbox
Set objNewMessage = objOutBox.Messages.Add
Set objRecipients = objNewMessage.Recipients
Set objOneRecip = objRecipients.Add
objOneRecip = Recip
With objNewMessage
.Subject = Subj
.Text = Body
.Send
End With
End Sub
Sub StartMessagingAndLogon()
Dim sKeyName As String
Dim sValueName As String
Dim sDefaultUserProfile As String
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
On Error GoTo ErrorHandler
Set objSession = CreateObject("MAPI.Session")
'Try to logon. If this fails, the most likely reason is
'that you do not have an open session. The error
'-2147221231 MAPI_E_LOGON_FAILED will return. Trap
'the error in the ErrorHandler
objSession.Logon ShowDialog:=False, NewSession:=False
Exit Sub
ErrorHandler:
Select Case Err.Number
Case -2147221231 'MAPI_E_LOGON_FAILED
'Need to find out what OS is in use, the keys are different
'for WinNT and Win95.
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionEx(osinfo)
Select Case osinfo.dwPlatformId
Case 0 'Unidentified
MsgBox "Unidentified Operating System. Can't log onto
messaging."
Exit Sub
Case 1 'Win95
sKeyName = "Software\Microsoft\Windows Messaging
Subsystem\Profiles"
Case 2 'NT
sKeyName = "Software\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles"
End Select
sValueName = "DefaultProfile"
sDefaultUserProfile = QueryValue(sKeyName, sValueName)
objSession.Logon ProfileName:=sDefaultUserProfile, ShowDialog:=False
Exit Sub
Case Else
MsgBox "An error has occured while attempting" & Chr(10) & _
"To create and logon to a new ActiveMessage session." & _
Chr(10) & "Please report the following error to your " & _
"System Administrator." & Chr(10) & Chr(10) & _
"Error Location: frmMain.StartMessagingAndLogon" & _
Chr(10) & "Error Number: " & Err.Number & Chr(10) & _
"Description: " & Err.Description
End Select
End Sub
Public Function CheckInbox(LastChecked As Date)
Dim objInbox As Folder
Dim objMessages As Messages
'Dim objMsgFilter As MessageFilter
Dim objOneMessage As Message
Dim MailBox(1 To 1000, 1 To 6) As Variant
Dim I As Integer
Dim X As Integer
Dim Y As Integer
Dim temp As String
X = 0
'StartMessagingAndLogon
objSession.Logon frmLogin.txtUserName, frmLogin.txtPassword, True, True
Set objInbox = objSession.Inbox
Set objMessages = objInbox.Messages
'Set objMsgFilter = objMessages.Filter
'objMsgFilter.Unread = False
For I = 1 To objMessages.Count
Set objOneMessage = objMessages.Item(I)
If objOneMessage.TimeReceived > LastChecked Then
X = X + 1
MailBox(X, 1) = X
For Y = 2 To 6
Select Case Y
Case 2
temp = objOneMessage.Sender
Case 3
temp = objOneMessage.Subject
Case 4
temp = objOneMessage.Text
Case 5
temp = objOneMessage.TimeReceived
Case 6
On Error Resume Next
If IsNull(objOneMessage.Recipients(1)) Then
temp = ""
Else
temp = objOneMessage.Recipients(1)
End If
On Error GoTo 0
End Select
MailBox(X, Y) = temp
Next Y
End If
Next I
CheckInbox = MailBox
Set objSession = Nothing
End Function
Public Function Resolver(Email As String) As String
Dim objOutBox As Folder
Dim objNewMessage As Message
Dim objRecipients As Recipients
Dim objOneRecip As Recipient
StartMessagingAndLogon
Set objOutBox = objSession.Outbox
Set objNewMessage = objOutBox.Messages.Add
Set objRecipients = objNewMessage.Recipients
Set objOneRecip = objRecipients.Add
With objOneRecip
'Fill in an appropriate alias here
.Name = Email
.Type = ActMsgTo
Resolver = .Resolve ' get MAPI to determine complete e-mail address
End With
Set objOutBox = Nothing
Set objNewMessage = Nothing
Set objRecipients = Nothing
Set objOneRecip = Nothing
End Function
Sub Respond(TimeChecked As Date)
Dim Arr As Variant
Dim Con As New ADODB.Connection
Dim RSEmails As New ADODB.Recordset
Dim RSCustomers As New ADODB.Recordset
Dim Addy As String
Dim temp As String
Dim I As Integer
Dim J As Integer
Dim X As Integer
Set Con = New ADODB.Connection
With Con
.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=" &
App.Path & "\ARBack.mdb;"
.Open
End With
RSEmails.Open "SELECT * FROM Outgoing", Con, adOpenForwardOnly,
adLockOptimistic, adCmdText
RSCustomers.Open "SELECT * FROM Customers", Con, adOpenDynamic,
adLockOptimistic, adCmdText
RSEmails.MoveFirst
Arr = CheckInbox(TimeChecked)
For I = 1 To UBound(Arr)
For J = 1 To 6
If Arr(I, J) = "" Then
Exit Sub
End If
Next J
'this is where we do the comparison
Do While Not RSEmails.EOF
Select Case RSEmails!qualifier
Case "sent from"
X = 2
Case "sent to"
X = 6
Case "with subject of"
X = 3
End Select
If InStr(0, Arr(I, 2), "@", vbBinaryCompare) = 0 Then
temp = Arr(I, 2)
Addy = Resolver(temp)
Else
Addy = Arr(I, 2)
End If
If Arr(I, X) = RSEmails!object Then
SendMail Addy, RSEmails!Subject, RSEmails!Body
RSCustomers.AddNew
RSCustomers![login ID] = frmLogin.txtUserName
RSCustomers!emailname = Addy
RSCustomers!Category = RSEmails!Category
RSCustomers!LetterSent = RSEmails!EmailID
RSCustomers.Update
End If
Loop
RSEmails.MoveFirst
Next I
End Sub
System Tray Module:
'user defined type required by Shell_NotifyIcon API call
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type
'constants required by Shell_NotifyIcon API call:
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201 'Button down
Public Const WM_LBUTTONUP = &H202 'Button up
Public Const WM_LBUTTONDBLCLK = &H203 'Double-click
Public Const WM_RBUTTONDOWN = &H204 'Button down
Public Const WM_RBUTTONUP = &H205 'Button up
Public Const WM_RBUTTONDBLCLK = &H206 'Double-click
Public Declare Function SetForegroundWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public nid As NOTIFYICONDATA
There is Forms frmLogin, frmOutgoing1, frmUndercover, which is the start up
screen.
frmLogin Code:
Option Explicit
Dim MyCount As Integer
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
End
End Sub
Private Sub cmdOK_Click()
If MyCount <= 1 Then
MyCount = MyCount + 1
CheckPass
Else
MsgBox "You don't have an account or you are not using the correct
password. Good bye.", vbCritical
End
End If
End Sub
Private Sub CheckPass()
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Dim MyText As String
Set DB = DBEngine.OpenDatabase(App.Path & "\ARBack.mdb")
Set RS = DB.OpenRecordset("users", dbOpenDynaset)
RS.FindFirst "[Login ID] = '" & txtUserName & "'"
If RS.NoMatch Then
On Error Resume Next
MyText = InputBox("You are a new user. Please verify your Password, or
click cancel to exit.", "AutoResoponder Request for Information")
If MyText = "" Then
MsgBox "You must assign a password."
Exit Sub
Else
If MyText = txtPassword Then
RS.AddNew
RS("Login ID") = txtUserName
RS("Password") = MyText
RS.Update
Me.Hide
StrSQL = "SELECT * FROM Outgoing WHERE [Login ID] = '" &
Me("txtUserName") & "'"
MsgBox StrSQL
Load frmOutgoing1
frmOutgoing1("datPrimaryRS").RecordSource = StrSQL
frmUnderCover.Show
Exit Sub
End If
End If
Else
If RS("password") = txtPassword Then
Me.Hide
StrSQL = "SELECT * FROM Outgoing WHERE [Login ID] = '" &
Me("txtUserName") & "'"
'MsgBox StrSQL
Load frmOutgoing1
frmOutgoing1("datPrimaryRS").RecordSource = StrSQL
frmUnderCover.Show
Exit Sub
Else
MsgBox "You have entered an invalid password. Please try again.",
vbOKOnly, "Invalid Password"
txtPassword = ""
txtPassword.SetFocus
Exit Sub
End If
End If
End Sub
frmOutgoing1 Code:
Option Explicit
Dim AddRec As Boolean
Private Sub cboQualifier_Validate(Cancel As Boolean)
If Me("cboqualifier") = "Sent to" Or Me("cboqualifier") = "Sent from" Or
Me("cboqualifier") = "With subject of" Then
Cancel = False
Exit Sub
Else
MsgBox "You must enter an item from the list", vbCritical, "Validation
error"
Me!cboQualifier = "With subject of"
Cancel = True
End If
End Sub
Private Sub CmdClose_Click()
frmUnderCover.Show
Unload Me
End Sub
Private Sub cmdEdit_Click(Index As Integer)
UnlockAllControls
End Sub
'Private Sub cmdEdit_Click()
' UnlockAllControls
'End Sub
Private Sub Form_Load()
With Me("datPrimaryRS")
.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=" &
App.Path & "\ARBack.mdb;"
.RecordSource = StrSQL
End With
Me("datPrimaryRS").Refresh
If Not AddRec Then
LockAllControls
End If
AddRec = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmUnderCover.Show
Screen.MousePointer = vbDefault
End Sub
Private Sub datPrimaryRS_Error(ByVal ErrorNumber As Long, Description As
String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String,
ByVal HelpContext As Long, fCancelDisplay As Boolean)
'This is where you would put error handling code
'If you want to ignore errors, comment out the next line
'If you want to trap them, add code here to handle them
MsgBox "Data error event hit err:" & Description
End Sub
'Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum,
ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal
pRecordset As ADODB.Recordset)
' 'This will display the current record position for this recordset
' Dim ThisRec As String
' Dim LastRec As String
'
' ThisRec = CStr(datPrimaryRS.Recordset.AbsolutePosition)
'
' If Not datPrimaryRS.Recordset.EOF Then
'
' LastRec = CStr(datPrimaryRS.Recordset.RecordCount)
' Else
' ThisRec = 0
' LastRec = ThisRec
' End If
'
' datPrimaryRS.Caption = "
Outgoing Mail Record " & ThisRec & " of " & LastRec
'
' If AddRec Then
' UnlockAllControls
' Else
' LockAllControls
' End If
'
'End Sub
'Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As
ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As
ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
' 'This is where you put validation code
' 'This event gets called when the following actions occur
' Dim bCancel As Boolean
'
' Select Case adReason
' Case adRsnAddNew
' Case adRsnClose
' Case adRsnDelete
' Case adRsnFirstChange
' Case adRsnMove
' Case adRsnRequery
' Case adRsnResynch
' Case adRsnUndoAddNew
' Case adRsnUndoDelete
' Case adRsnUndoUpdate
' Case adRsnUpdate
' End Select
If bCancel Then adStatus = adStatusCancel
End Sub
Private Sub cmdAdd_Click()
On Error GoTo AddErr
UnlockAllControls
Me!LoginID = frmLogin!txtUserName
AddRec = True
datPrimaryRS.Recordset.AddNew
Me.txtFields(0).SetFocus
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub cmdDelete_Click()
On Error GoTo DeleteErr
With datPrimaryRS.Recordset
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
Exit Sub
DeleteErr:
MsgBox Err.Description
End Sub
Private Sub cmdUpdate_Click()
On Error GoTo UpdateErr
Me.LoginID = frmLogin("txtUsername")
datPrimaryRS.Recordset.UpdateBatch adAffectAll
LockAllControls
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
Private Sub UnlockAllControls()
Dim CTL As Control
For Each CTL In Me.Controls
If CTL.Tag = "Tan" Then
CTL.Enabled = True
End If
Next CTL
End Sub
Private Sub LockAllControls()
Dim CTL As Control
For Each CTL In Me.Controls
If CTL.Tag = "Tan" Then
CTL.Enabled = False
End If
Next CTL
End Sub
frmUnderCover Code:
Option Explicit
Dim Working As Boolean
Private Sub Form_Load()
Me!Image3.Picture = Me!Image1.Picture
Me!imgExit.Picture = Me!ExitUnclick.Picture
Me!imgStartService.Picture = Me!StartServiceUnclick.Picture
'the form must be fully visible before calling Shell_NotifyIcon
Me.Show
Me.Refresh
With nid
.cbSize = Len(nid)
.hwnd = Me.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon
.szTip = "Autoresponder (tm)" & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, nid
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim Frm As Form
'this removes the icon from the system tray
Shell_NotifyIcon NIM_DELETE, nid
For Each Frm In Forms
Unload Frm
Next Frm
End
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y
As Single)
'this procedure receives the callbacks from the System Tray icon.
Dim Result As Long
Dim msg As Long
'the value of X will vary depending upon the scalemode setting
If Me.ScaleMode = vbPixels Then
msg = X
Else
msg = X / Screen.TwipsPerPixelX
End If
Select Case msg
Case WM_LBUTTONUP '514 restore form window
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
Case WM_LBUTTONDBLCLK '515 restore form window
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
Case WM_RBUTTONUP '517 display popup menu
Result = SetForegroundWindow(Me.hwnd)
Me.PopupMenu Me.mPopupSys
End Select
End Sub
Private Sub Form_Resize()
'this is necessary to assure that the minimized window is hidden
If Me.WindowState = vbMinimized Then Me.Hide
End Sub
Private Sub Image3_Click()
Load frmOutgoing1
Me.Hide
Working = False
frmOutgoing1.Show
End Sub
Private Sub Image3_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
Me!Image3.Picture = Me!Image2.Picture
End Sub
Private Sub Image3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y
As Single)
Me!Image3.Picture = Me!Image1.Picture
End Sub
Private Sub imgExit_Click()
Unload Me
End Sub
Private Sub imgExit_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
Me!imgExit.Picture = Me!ExitClick.Picture
End Sub
Private Sub imgExit_MouseUp(Button As Integer, Shift As Integer, X As Single, Y
As Single)
Me!imgExit.Picture = Me!ExitUnclick.Picture
End Sub
Private Sub imgStartService_Click()
StartLoop
Me.WindowState = 1
End Sub
Private Sub imgStartService_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me!imgStartService.Picture = Me!StartServiceClick.Picture
End Sub
Private Sub imgStartService_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me!imgStartService.Picture = Me!StartServiceUnclick.Picture
End Sub
Private Sub mPopExit_Click()
'called when user clicks the popup menu Exit command
Unload Me
End Sub
Private Sub mPopRestore_Click()
Dim Result As Long
'called when the user clicks the popup menu Restore command
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
End Sub
Private Sub StartLoop()
Dim DB As DAO.Database
Dim Sender As String
Dim RSUsers As DAO.Recordset
Dim RSOutgoing As DAO.Recordset
Dim RSCustomer As DAO.Recordset
Dim TempUser As String
Dim I As Integer
On Error GoTo ServiceHandler
Working = True
Set DB = DBEngine.OpenDatabase(App.Path & "\ARBack.mdb")
DoEvents
On Error GoTo 0
Set RSUsers = DB.OpenRecordset("Users", dbOpenSnapshot)
Set RSOutgoing = DB.OpenRecordset("SELECT * FROM outgoing WHERE [Login ID]
= '" & RSUsers("Login ID") & "'", dbOpenDynaset)
Set RSCustomer = DB.OpenRecordset("Customers", dbOpenDynaset)
If RSOutgoing.EOF Then
MsgBox "You have no outgoing messages entered. Please go back to the
main menu and select 'Add\Edit Emails'", vbInformation, "No Valid outgoing
messages"
imgStartService.Picture = Me.StartServiceUnclick.Picture
Exit Sub
End If
DoEvents
TempUser = RSUsers("Login ID")
Do While Not RSUsers.EOF
If TempUser <> RSUsers("Login ID") Then
GetSessID RSUsers("Login ID"), RSUsers("Password")
Set RSOutgoing = DB.OpenRecordset("SELECT * FROM outgoing WHERE
[Login ID] = '" & RSUsers("Login ID") & "'", dbOpenDynaset)
Me.MAPIMessages1.Fetch
End If
Do While I <= Me.MAPIMessages1.MsgCount - 1
If Me.MAPIMessages1.MsgCount = 0 Then
Exit Do
End If
Me.MAPIMessages1.MsgIndex = I
If CDate(Me.MAPIMessages1.MsgDateReceived) >
DB.Properties("lastchecked") Then
Do While Not RSOutgoing.EOF
If InStrRev(Me.MAPIMessages1.MsgOrigAddress, "=") = 0 And
Me.MAPIMessages1.MsgOrigAddress <> "" Then
Sender = Right(Me.MAPIMessages1.MsgOrigAddress,
Len(Me.MAPIMessages1.MsgOrigAddress) - 5)
Else
Sender = Right(Me.MAPIMessages1.MsgOrigAddress,
(Len(Me.MAPIMessages1.MsgOrigAddress) -
InStrRev(Me.MAPIMessages1.MsgOrigAddress, "=")))
End If
If RSOutgoing("Qualifier") = "sent from" And UCase(Sender)
= UCase(RSOutgoing("Object")) Then
SendMail RSOutgoing("subject"), RSOutgoing("Body"),
Sender
AddCustomer RSOutgoing("category"), Sender,
RSOutgoing("Email ID"), False
End If
If RSOutgoing("Qualifier") = "sent to" And
UCase(RSOutgoing("Login ID")) = UCase(Left(Me.MAPIMessages1.RecipAddress,
InStr(Me.MAPIMessages1.RecipAddress, "@"))) Then
SendMail RSOutgoing("subject"), RSOutgoing("Body"),
Sender
AddCustomer RSOutgoing("category"), Sender,
RSOutgoing("Email ID"), False
End If
If RSOutgoing("Qualifier") = "with subject of" And
UCase(Me.MAPIMessages1.MsgSubject) = UCase(RSOutgoing("object")) Then
If UCase(Me.MAPIMessages1.MsgSubject) <> "REMOVE" Then
SendMail RSOutgoing("subject"), RSOutgoing("Body"),
Sender
AddCustomer RSOutgoing("category"), Sender,
RSOutgoing("Email ID"), False
Else
AddCustomer RSOutgoing("category"), Sender,
RSOutgoing("email ID"), True
End If
End If
RSOutgoing.MoveNext
Loop
RSOutgoing.MoveFirst
End If
If I = Me.MAPIMessages1.MsgCount - 1 Then
Me.MAPIMessages1.MsgIndex = I
DB.Properties("LastChecked") = Me.MAPIMessages1.MsgDateReceived
End If
I = I + 1
DoEvents
Loop
TempUser = RSUsers("Login ID")
RSUsers.MoveNext
Loop
Set DB = Nothing
Set RSOutgoing = Nothing
Set RSCustomer = Nothing
DoEvents
Working = False
Exit Sub
ServiceHandler:
If Err.Number = 3270 Then
Dim Prop As DAO.Property
Set Prop = DB.CreateProperty("LastChecked", dbDate, Now(), True)
DB.Properties.Append Prop
Err.Clear
Resume Next
End If
If Err.Number = 32002 Then
Err.Clear
Exit Sub
End If
End Sub
Private Sub Timer1_Timer()
If Not Working Then
StartLoop
End If
End Sub
Private Sub AddCustomer(Category As String, Sender As String, LetterSent As
String, Remove As Boolean)
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Set DB = DBEngine.OpenDatabase(App.Path & "\ARBack.mdb")
Set RS = DB.OpenRecordset("Customers", dbOpenDynaset)
If Not Remove Then
RS.FindFirst "[Email Name] = '" & Sender & "'"
If RS.NoMatch Then
RS.AddNew
RS("Login ID") = frmLogin.txtUserName
RS("Email Name") = Sender
RS("Category") = Category
RS("letter Sent") = LetterSent
RS.Update
Else
RS.Edit
RS("letter sent") = LetterSent
RS.Update
End If
Else
RS.FindFirst "[Email Name] = '" & Sender & "'"
RS.Delete
End If
Set RS = Nothing
Set DB = Nothing
End Sub
Private Sub SendMail(Subject As String, Body As String, Sender As String)
Me.MAPIMessages1.Compose
Me.MAPIMessages1.MsgSubject = Subject
Me.MAPIMessages1.MsgNoteText = Body
Me.MAPIMessages1.RecipAddress = Sender
Me.MAPIMessages1.AddressResolveUI = True
Me.MAPIMessages1.ResolveName
Me.MAPIMessages1.Send False
End Sub
Private Sub GetSessID(uId As String, PWD As String)
On Error GoTo GetSesshandler
Me.MAPISession1.UserName = uId
Me.MAPISession1.Password = PWD
Me.MAPISession1.SignOn
Me.MAPIMessages1.SessionID = Me.MAPISession1.SessionID
Exit Sub
GetSesshandler:
If Err.Number = 32003 Then
MsgBox "You failed to enter a valid User ID and Password. You will now
be logged off. If you know the name of your mail server, you can set up a new
profile and password by clicking the 'New' button when prompted for a
password.", vbCritical, "Invalid UID and PWD"
Unload Me
End If
End Sub
If this can be done, the code is here for you to make your own Autoresponder,
but even in VB6, with all the Security updates it won't work now. I hope there
is a workaround?
Michael
- 15
- Visual Basic >> Visual Basic Communication with Serial Port RS232I am attempting to use visual basic to perform a few seemingly simple tasks,
but I have been unsuccessful to do so. I am trying to write a code that can
communicate through a serial port to a microcontroller. All I need the code
to do is to open a com port on my computer, send it the letter g (which
triggers the microcontroller to send back an array of data) and receive an
array of data and write it to a text file. The microcontroller array is a
1440 X 7 array, and all I need the code to do is somehow get this through
the serial port to my computer and make a text file that has the array. If
you know of any way to do this, or anyone who could possibly help me I would
be very greatful! If someone is available, or I need to pay for help
(reasonably of course) I am willing to do so. Thank you for taking the time
to read this and I hope someone out there can find a chance to help me out!
|
| Author |
Message |
jfigueredo

|
Posted: Mon Oct 06 13:30:32 CDT 2003 |
Top |
Visual Studio C++ >> Can VC++ 6.0 build 64-bit apps?
Hi:
Can we use Visual C++ 6.0 to build 64-bit applications on a 64-bit platform
(Windows Server 2003) ? If yes, is there any special steps that must be
taken to do it?
Thansk
Visual Studio245
|
| |
|
| |
 |
Carl

|
Posted: Mon Oct 06 13:30:32 CDT 2003 |
Top |
Visual Studio C++ >> Can VC++ 6.0 build 64-bit apps?
Polaris wrote:
> Hi:
>
> Can we use Visual C++ 6.0 to build 64-bit applications on a 64-bit
> platform (Windows Server 2003) ? If yes, is there any special steps
> that must be taken to do it?
No, you cannot.
You Can, however, use the 64-bit compiler that's included in the Platform
SDK.
-cd
|
| |
|
| |
 |
Kobi

|
Posted: Mon Oct 06 13:32:03 CDT 2003 |
Top |
Visual Studio C++ >> Can VC++ 6.0 build 64-bit apps?
Polaris,
> Can we use Visual C++ 6.0 to build 64-bit applications on a 64-bit
platform
> (Windows Server 2003) ? If yes, is there any special steps that must be
> taken to do it?
Yes you can, but need to make some adjustments.
See Tian Min Huang's explanation:
http://tinyurl.com/pwu
--
Regards,
Kobi Ben Tzvi
"Polaris" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Hi:
>
> Can we use Visual C++ 6.0 to build 64-bit applications on a 64-bit
platform
> (Windows Server 2003) ? If yes, is there any special steps that must be
> taken to do it?
>
> Thansk
>
>
|
| |
|
| |
 |
Kobi

|
Posted: Mon Oct 06 13:40:33 CDT 2003 |
Top |
Visual Studio C++ >> Can VC++ 6.0 build 64-bit apps?
Oops,
Wrong url...
http://tinyurl.com/pwuw
--
Regards,
Kobi Ben Tzvi
"Kobi Ben Tzvi" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Polaris,
>
> > Can we use Visual C++ 6.0 to build 64-bit applications on a 64-bit
> platform
> > (Windows Server 2003) ? If yes, is there any special steps that must be
> > taken to do it?
>
> Yes you can, but need to make some adjustments.
> See Tian Min Huang's explanation:
> http://tinyurl.com/pwu
>
> --
> Regards,
> Kobi Ben Tzvi
>
>
> "Polaris" <EMail@HideDomain.com> wrote in message
> news:EMail@HideDomain.com...
> > Hi:
> >
> > Can we use Visual C++ 6.0 to build 64-bit applications on a 64-bit
> platform
> > (Windows Server 2003) ? If yes, is there any special steps that must be
> > taken to do it?
> >
> > Thansk
> >
> >
>
>
|
| |
|
| |
 |
| |
 |
Index ‹ Visual Studio ‹ Visual Studio C++ |
- Next
- 1
- Visual Studio C++ >> About Wintrust.hHi,
I was compiling an application that includes a file called wintrust.h in the
VS dir. However, its presence shows some annoying errors and just when
excluding this file, no problems exist. I'm using VC6 now and when using
.NET to compile, I face another set of problems..
Thanks
Jack
- 2
- VB Scripts >> folder sizeI have to find out the folder size on a network drive that I have access to.
I have access to the drive but not all the folders in the drive. Can someone
help me please. like do for each loop, but also skip the folder that I do not
have access to
- 3
- Visual Basic >> datagrid using vb6.0 and ADOHi,
I tried to add the data from a datagrid using vb6.0 and ADO, I can add but
only row by row from the datagrid, but I wanted to be added all the rows
which are populated in that datagrid in a single step, I used the next code
for adding:
Dim rstadd As ADODB.Recordset
Set rstadd = New ADODB.Recordset
Dim siruladd As String
siruladd = "select * from carriers_rates "
rstadd.Open siruladd, Conex
With rstadd
.Filter = "carrier_code='" & frmImport!txtCarrierCode.Text & "' AND
concatenate_code_by_carrier='" & frmImport!dgImport.Columns(1).Text & "' AND
date='" & frmImport!dtpData.Value & "' "
If .RecordCount = 0 Then
.AddNew
rstadd!carrier_code = frmImport!txtCarrierCode.Text
rstadd!area_name = frmImport!dgImport.Columns(0).Text
rstadd!concatenate_code_by_carrier = frmImport!dgImport.Columns(1).Text
rstadd!Rate = frmImport!dgImport.Columns(2).Text
rstadd!effective_date = frmImport!dgImport.Columns(3).Text
rstadd!Data = frmImport!dtpData.Value
.Update
Else
MsgBox ("Inregistrarea a fost facuta, selectati un alt carrier!")
End If
End With
'****************************************************************************************************************
Do you know what I have to do for this adding?
Thank you
- 4
- VB Scripts >> Server Side Code Returning Invalid XML errorHi fellows,
I am a newbie, so new to these discussion groups. I had put this question in
Sqlserver.xml group. May be this question is related to ASP group. So,
putting it here. I am facing following problem:
I am passing a XML to SP, and SP in return send XML back. When I comment out
sp_xml_preparedocument (XML reading block) in SP, ASP is taking returning XML
as valid, but, if I uncomment input XML reading block, ASP is giving
following error:
--------------------------------------
Microsoft OLE DB Provider for SQL Server error '80040e21'
XML parsing error: Invalid at the top level of the document.
/../../MailListFixErrors.asp, line 124
--------------------------------------
I am using XP v2002 SP2, Sql-Server 2K Pro. Edition SP3 and using classic
ASP.
Here is my code snippet:
Store Proc:
-------------
CREATE PROC [dbo].[spValidateMList_MLST]
@XMLDoc text
AS
BEGIN
DECLARE @InputList TABLE (
[MailListName] [varchar] (40) ,
[guid] [varchar] (40) )
DECLARE
@MailListName [varchar] (40) ,
@CustomerID [varchar] (40) ,
@ShipperID [varchar] (40) ,
@ServerID [varchar] (40)
EXEC sp_xml_preparedocument @idoc OUTPUT, @XMLDoc
SELECT @MailListName= MailListName,
@CustomerID= CustomerID,
@ShipperID= ShipperID,
@ServerID= ServerID
FROM OPENXML (@idoc, '/maillist',2)
WITH (maillistname [varchar] (40) ,
customerid [varchar] (40) ,
shipperid [varchar] (40) ,
serverid [varchar] (40) )
INSERT INTO @InputList
( MailListName, guid )
SELECT @MailListName, guid
FROM OPENXML (@idoc, '/maillist/row',2)
WITH (guid [varchar] (40) )
EXEC sp_xml_removedocument @idoc
......
......
SELECT
1 AS Tag,
NULL AS Parent,
NULL AS [Error!1!],
NULL AS [row!2!Code!element],
NULL AS [row!2!Message!element]
UNION ALL
SELECT
2 AS Tag,
1 AS Parent,
NULL AS [Error!1!],
0 AS [row!2!Code!element],
(SELECT COUNT(*) AS ErrCount
FROM @MailListShipment
WHERE CheckedStatus in (1,2))
AS [row!2!Message!element]
FOR XML EXPLICIT
END
ASP code is as :
-------------------
Dim strExStoredProcedure
Const MSSQLXML_DIALECT = "{5d531cb2-e6ed-11d2-b252-00c04f681b71}"
Const adExecuteStream = 1024
Const adWriteChar = 0
Dim conDB
Dim cmdXML
Dim stmXMLin
Dim stmXMLout
strExStoredProcedure= " [dbo].[spValidateMList_MLST] @XMLDoc = " &_
"'<maillist><maillistname>ml14</maillistname><customerid>ABC</customerid> "
&_
"<shipperid>ABC</shipperid><serverid>s400</serverid><row> " &_
"<guid>D3EA3AA2-49EC-4455-8D25-6D32BAD3D6DB</guid></row></maillist>' "
Set conDB = CreateObject("ADODB.Connection")
With conDB
.Provider = "SQLOLEDB"
.ConnectionString = connstr
.Open
End With
Set cmdXML = CreateObject("ADODB.Command")
Set cmdXML.ActiveConnection = conDB
Set stmXMLin = CreateObject("ADODB.Stream")
Set stmXMLout = CreateObject("ADODB.Stream")
With stmXMLin
.Open
.WriteText "<root xmlns:sql='urn:schemas-microsoft-com:xml-sql'>",
adWriteChar
.WriteText "<sql:query>", adWriteChar
.WriteText "EXEC " & strExStoredProcedure, adWriteChar
.WriteText "</sql:query></root>", adWriteChar
.Position = 0
End With
'Open Stream for output
stmXMLout.Open
With cmdXML
Set .CommandStream = stmXMLin
.Dialect = MSSQLXML_DIALECT
.Properties("Output Stream") = stmXMLout 'Output Stream
.Execute, ,adExecuteStream 'Execute ADO Command
End With
str=stmXMLout.ReadText 'get the XML as string
This SP runs fine in Query Analyzer and the returning XML seems to be OK.
But when we use â??Responseâ?? Object to get returning XML, and pass it back to
client side, it is working OK. But if I use "stmXMLout" Object Stream to get
returning XML, and want to process XML on server side code, it is giving me
the error I mentioned above.
Need help ASAP.
Thanks.
- 5
- Mcse >> virtual labsI' trying to use the virtual labs to learn more about Remote Desktop for
Administration and Remote Assistance .
I can connect to it but cannot control the virtual machine ie at the
server
login screen ctrl+alt+ delete, it does not work, I am still controlling
my
own pc (it brings up task mgr!)
please help,
- 6
- 7
- VB Scripts >> Pulling an Access Report from an Outlook FormHello,
I'm using (attempting to use) VBScript to pull up an Access Report from
an Outlook form and I keep getting the following errors:
1. operation is not allowed when the object is open
2. database does not exist or else it is open excusivley to another
user
Error 2 occurs with the code below and I get error 1 when I remove
strDBName. Can anyone please help me out? Thank you!
Sub Get_Click()
Dim objConnection
Dim objAccess
Dim strRptName
Dim strDBName
Dim objAddress
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=K:\PSHARE\Sourcing Department Structure\Procurement Services
Project Database\1DepartmentData.mdb;"
strDBName = objConnection.open
strRptName = "rpt_Projects_Detail"
Set objAccess = CreateObject("Access.Application")
objAccess.Visible = False
objAccess.OpenCurrentDatabase strDBName
with objAddress.DoCmd
.OpenReport strRptName, acViewPreview
.Close
end with
objaccess.Quit acQuitSaveNone
set objAccess = Nothing
Set objConnection = Nothing
end sub
--
kshipp99
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
- 8
- VB Scripts >> Adding users to groups in ADI have the code from the TechNet Script center for adding users to groups
which works great. But what do you do if you do not know the OU the user is
in. Is there a way to search AD and return the value so that it can be
passed to the code which will be adding the users to the group. I am
interested in on creating a utility to add members to a group by providing a
list of users in a text file.
Paul Glickenhaus
- 9
- Visual Basic >> SQL In 2 DatabasesHi Group
I was wondering how i could get my simple SQL query to check through 2
databases?
Both databases are in c:\data\
Called maindata.mdb & backdata.mdb
both need to be search in table2
My SQL is currently just "Select * From Table2"
Any ideas?
Thanks!
- 10
- Visual Basic [VB] >> How to reload MDI Child Form into Parent Form.Hi VB.Net Gurus.
Initial MDI Child form loads fine.
exp.
Dim objChild2 As New Form2()
objChild2.MdiParent = Me
objChild2.Show()
MDI Child unloads just fine.
Exp.
If e.Button Is tbbExit Then
'' Me.Close()
Me.Hide()
rs.Close()
cn.Close()
End If
The MDI Child reload does not reload into the parent form.
It reloads outside the parent form.
exp.
Dim oForm As New Form2()
oForm.MdiParent = Me.ActiveMdiChild
oForm.Show()
Regards,
Tony
- 11
- Visual Basic [VB] >> winforms vb.net asp.net conversionHi all,
We have a vb.net app (WinForms) that has been running for a while now
in production. We'd now like to make it into a thin client by moving
to a web-based application and asp.net.
I'm not very familiar with asp.net, but am very familiar with vb.net.
Does anyone have any recommendations on how to start this process ?
I'd like to avoid having to re-write major portions of the application.
How well to WinForm controls move over to ASP ?
Any ideas would be most appreciated.
Mark
- 12
- 13
- MFC >> equating handleshi,
I have a problem in equating two HANDLE's.
the code is
if( (m_SocketManager1[i].m_hThread != cl.GetAt(p).h))
here "m_SocketManager1[i].m_hThread" is a HANDLE,
"cl.GetAt(p).h" is a HANDLE
now even though both the HANDLE's are same it goes in to the condition. I
can see in the debugger that they both are equal.
Any help on this is appreciated.
Thank you
- 14
- VB Scripts >> Login script to redirect LPT1 to Terminal Server remote client priI am trying to find a way to create a script that runs when my client
connects to a Terminal Server. I want the script to determine if the remote
client computer has a connected printer. If it does, I want the script to
SHARE that printer and then redirect LPT1 output to that SHARE using the NET
USE command.
STEP 1 - This command outputs the raw information about the default printer.
If the port the printer is connected to begins with 'TS' then it is indeed a
terminal server session printer. The printer name needs to be isolated to a
variable to be passed to the second command and the 'TS' port should be
passed as the SHARE NAME so that it is unique and does not conflict with
other users' shares:
reg query "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows" /V
Device
STEP 2 - The following command will share a printer from a
command line. :
cscript c:\windows\system32\prncnfg.vbs -t -p "<printername from above
step>" -h "<sharename using TS port info from above step>" +shared
STEP 3 - NET USE LPT1: \\<TerminalServerName>\<Sharename>
Alternatively, if anyone can direct me to a good online VBScript reference
guide I would be happy to figure out how to write this myself.
Thanks,
Tom Shubert
- 15
- Visual Basic [VB] >> Writing to registry - REG_BINARY typeHi All,
Did an export from the registry (see below). This is what I need to have
written to the registry programmatically from my VB.NET utility. As you can
see it is multi-line and binary data. Had no problems with the other
entries written to the registry using:
Dim shell as Object
shell.RegWrite(strRegDir, strSigName, "REG_EXPAND_SZ")
----------------------------------------
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Common\MailSettings]
"ReplyFontSimple"=hex:3c,00,00,00,0f,00,00,e8,00,00,00,00,c8,00,00,00,d8,01,59,\
00,00,00,ff,00,00,20,41,72,69,61,6c,00,44,05,0e,00,00,00,00,00,00,00,00,00,\
00,00,00,00,58,df,66,34,8c,ea,13,00,01,00,00,00
----------------------------------------
TIA!
Mike D.
|
|
|