|
|
Hi,
1.
you can reach a list of your latest messages through your profile page; see here[^]. The message you have somehow lost is now the second on that list.
2.
Your question was asked and answered two days ago.
3.
If you were getting strange results, I haven't found a reason yet to blame VS2010.
|
|
|
|
|
It maybe would help if you read the documentation for both Operands, rather than dismiss your previous answers and ask again.
The \ operand will always raise a DivideByZero Exception.
The / operand will raise different exception depending on the type, from the Docs;
If expression2 evaluates to zero, the / operator behaves differently for different operand data types. The following table shows the possible behaviors.
Floating-point ( Single or Double) : Returns infinity ( PositiveInfinity or NegativeInfinity), or NaN (not a number) if expression1 is also zero
Decimal : Throws DivideByZeroException
Integral (signed or unsigned) : Attempted conversion back to integral type throws OverflowException because integral types cannot accept PositiveInfinity, NegativeInfinity, or NaN
|
|
|
|
|
In rewriting a website, I have found it useful to be able to select the first non-empty value from a list, where "empty" is defined as Nothing , DBNull.Value and String.Empty . The code I wrote looks like this:
Public Shared Function Coalesce(ByVal ParamArray Items() As Object) As Object
Dim Result As Object = Nothing
For Each Obj As Object In Items
If Obj IsNot Nothing AndAlso Obj IsNot DBNull.Value Then
If Not String.IsNullOrEmpty(Obj.ToString) Then
Result = Obj
Exit For
End If
End If
Next
Return Result
End Function
This way, I could write something like this:
Response.Write(Toolbox.Coalesce(DR("TerminatedDate"), "%nbsp;").ToString)
(Yeah, the nbsp is wrong; I couldn't get it to show up otherwise.) The inputs might be various types -- database fields, date variables, strings, etc. The output will almost always be converted into a String , but not necessarily.
This looks like it should do what I want, but I'm not fully convinced. Any suggestions on how to improve this?
|
|
|
|
|
I wrote an extension method for this not too long ago.
<System.Runtime.CompilerServices.Extension()> _
Public Function GetColumnAsString(ByVal rdr As System.Data.IDataReader, ByVal columnName As String, Optional ByVal valueIfNull As String = "") As String
Dim obj As Object
If rdr Is Nothing Then
Return valueIfNull
Else
obj = rdr(columnName)
If obj IsNot Nothing AndAlso obj.Equals(DBNull.Value) = False Then
Return obj.ToString()
Else
Return valueIfNull
End If
End If
End Function
Note: it does not check for make sure the column specified exists.
Using your example it would be
Response.Write(DR.GetColumnAsString("TerminatedDate", "%nbsp;"))
You could also embed it for more of a coalesce functionality.
Response.Write(DR.GetColumnAsString("TerminatedDate", DR.GetColumnAsString("SomeOtherDate", "%nbsp;"))
|
|
|
|
|
Does anyone has an idea how to implement single sign on using VB6/ASP?
|
|
|
|
|
Single Sign-on to what? You're going to have to explain what you want to do, beside just using "Single Sign-on".
|
|
|
|
|
I got application in ASP/VB6. I need to connect it to an application called Vebnet.
When a user logins my application he will have a link which will redirect him to Vebnet.
|
|
|
|
|
How is your application going to know what username/password to send to this application? How does this application ask for the credentials?? Do you have to source for this "Vebnet"?
You implement single-sign by writing code in the application that is going to support single sign on, not in some shell application that tries to force another app to accept a login.
|
|
|
|
|
Hi All
How can set visible properties false of PowerPoint? I am useing vb 6.0.
Dim pPT As PowerPoint.Application
Dim pPTopen As PowerPoint.Presentation
Dim PptName As String
PptName = "c:\nice.ppt"
Set pPT = New PowerPoint.Application
pPT.Visible = True
Set pPTopen = pPT.Presentations.Open(PptName)
How can i use pPT.Visible = False
When i use pPT.Visible = False then i got error.Error is here
Run-time error '-2147188160(80048240)'
Application (Unknown mwmber) : Invalied request.Hiding the application window is not allowed.
Thanks in advance
|
|
|
|
|
|
Thanks foe reply
But there is no +ve output.I need visible=False or hide powerpoint application.
There is no any option to hide or flas powerpoint application.
Please he me
|
|
|
|
|
what do you think of this
Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const ERR_NO_WINDOW_HANDLE As Long = 1000
Const ERR_WINDOW_LOCK_FAIL As Long = 1001
Const ERR_VERSION_NOT_SUPPORTED As Long = 1002
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As Long) As Long
Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long
Sub sOpenPowerpoint()
Dim pPT As PowerPoint.Application
Dim pPTopen As PowerPoint.Presentation
Dim PptName As String
PptName = "C:\A\Nice.pptx"
Set pPT = CreateObject("PowerPoint.Application")
pPT.Visible = True
Set pPTopen = pPT.Presentations.Open(PptName)
nHandle = fHandle
ShowWindow nHandle, SW_HIDE
End Sub
Function fHandle() As Long
Static hwnd As Long
Dim VersionNo As String
' Get Version Number
VersionNo = Left(Application.Version, InStr(1, Application.Version, ".") - 1)
' Get handle to the main application window using ClassName
Select Case VersionNo
Case "8" ' For PPT97:
hwnd = FindWindow("PP97FrameClass", 0&)
Case "9" ' For PPT2K:
hwnd = FindWindow("PP9FrameClass", 0&)
Case "10" ' For XP:
hwnd = FindWindow("PP10FrameClass", 0&)
Case "11" ' For 2003:
hwnd = FindWindow("PP11FrameClass", 0&)
Case "12" ' For 2007:
hwnd = FindWindow("PP12FrameClass", 0&)
Case Else
Err.Raise Number:=vbObjectError + ERR_VERSION_NOT_SUPPORTED, _
Description:="Supported for PowerPoint 97/2000/2002/2003 only."
Exit Function
End Select
If hwnd = 0 Then
Err.Raise Number:=vbObjectError + ERR_NO_WINDOW_HANDLE, _
Description:="Unable to get the PowerPoint Window handle"
Exit Function
End If
If LockWindowUpdate(hwnd) = 0 Then
Err.Raise Number:=vbObjectError + ERR_WINDOW_LOCK_FAIL, _
Description:="Unable to set a PowerPoint window lock"
Exit Function
End If
fHandle = hwnd
End Function
|
|
|
|
|
I guess you missed the copyright on that code snippet...
' --------------------------------------------------------------------------------
' Copyright ©1999-2009, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------
I don't mind you copy / pasting it really, but it fucking pisses me off that you don't at least give credit to the original link. (Here, by the way.[^])
and you could have posted the second entry on that page as well...
How to open a PowerPoint Show (*.pps) file thru code
It's fairly simple to open a PowerPoint file (*.ppt) for editing using VBA code however opening a PowerPoint Show (*.pps) file for editing is altogether another matter. Use the Presentation.Open method and it defaults to open the file in Slide Show mode. This might not be desirable. The routine below illustrates a manner of woring around the default behaviour and opening the file for editing. The routine also illustrates the use of the ScreenUpdating property (code listed above).
' --------------------------------------------------------------------------------
' Copyright ©1999-2009, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------
Sub OpenPPSForEdit()
On Error GoTo ErrHandle
Dim pShow As Presentation
' Lock the window to prevent refreshing
' See above article example for the code
ScreenUpdating = False
'Open the show, however use additional flag - WithWindow set to FALSE
Set pShow = Presentations.Open("C:\sample.pps", _
WithWindow:=msoFalse)
'Open a window now to the presentation for editing
pShow.NewWindow
' Unlock the window to start refreshing again
ScreenUpdating = True
Exit Sub
ErrHandle:
If Err.Number <> 0 Then
MsgBox Err.Number & " " & Err.Description, _
vbCritical + vbOKOnly, "Error"
End If
End Sub
|
|
|
|
|
I'm very sorry but I haven't read the remarques completly. It was my wrong thinking that it was already in the remarques. I read more carfully in the future.
However al that other code came also from internet.
|
|
|
|
|
It's Nice example.
But it's show error nHandle not define
modified on Friday, June 18, 2010 8:55 AM
|
|
|
|
|
|
I got again error
429 ActiveX component cann't create object
Please help me
modified on Friday, June 18, 2010 8:56 AM
|
|
|
|
|
in the declaration of handle its crearly tells function as long. So (almost) use the same datatype as the function
|
|
|
|
|
I am new to mdb data bases and trying to copy data from a column in one table to a column in another table.
Recently I wrote a short program to correct the data in one table of several mdb files. Below is the code I was using which works fine.
'removes unwanted characters from Optional Info23
Dim OpInfo23_upd As New OleDbCommand
OpInfo23_upd.CommandText = _
"UPDATE OP_INFO SET OPINFO23 = mid(OPINFO23,'2','8') & mid(OPINFO23,'11','2') WHERE OPINFO23 > ''"
OpInfo23_upd.Connection = conn
OpInfo23_upd.ExecuteNonQuery()
'sets flag character in Optional Info25
Dim OpInfo25_upd As New OleDbCommand
OpInfo25_upd.CommandText = _
"UPDATE OP_INFO SET OPINFO25 = mid(OPINFO23,'1','1')"
OpInfo25_upd.Connection = conn
OpInfo25_upd.ExecuteNonQuery()
Now I am attempting to add the code to copy the data from the NAME column in the required information table (REQ_INFO) to the OPINFO29 column in the optional information table (OP_INFO). I tried the code below, but it generates an exception. Is it possible to update the table directly from another table?
Dim OpInfo29_upd As New OleDbCommand
OpInfo29_upd.CommandText = _
"UPDATE OP_INFO SET OPINFO29 = REQ_INFO.NAME WHERE OP_INDEX = REQ_INFO.REQ_INDEX"
OpInfo29_upd.Connection = conn
OpInfo29_upd.ExecuteNonQuery()
|
|
|
|
|
And what is the exception message that is thrown?
|
|
|
|
|
No value given for one or more required parameters.
|
|
|
|
|
I think you need to do an inner join on the tables. Like:
UPDATE OP_INFO
INNER JOIN REQ_INFO ON OP_INFO.OP_INDEX = REQ_INFO.REQ_INDEX
SET OP_INFO.OPINFO29 = [REQ_INFO].[NAME];
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
modified on Thursday, June 17, 2010 5:20 PM
|
|
|
|
|
That worked perfectly. Thank you
|
|
|
|
|
Great. I had the table name wrong on the left-hand side of the SET but fixed it!
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
|
|
|
|