Wednesday, October 15, 2008

VB Best Faqs

1. How do you center a form?
2. Can I send keystrokes to a DOS application?
3. Convert an RGB value to a long, or a long to RGB.
4. Implement smooth scrolling for either text, graphics or controls across a form.
5. Implement some quick and easy encryption (can be something primitive).
6. 4 different types of sorts: advantages and disadvantages.
7. Compute CRC32 checksum, write a quick piece of code that accepts the packet of data and returns the CRC.
8. How do you use the Mouse OFF event?
9. How do I call Windows Help files from a VB program?
10. How do I create a textbox that lets you insert tabs?
11. How do I make text box that displays asterisks when the user types in data such as password?
12. How do I create multi-column combo box?
13. How do I make a menu popup from a CommandButton?
14. How to create menus at run time in VB?
15. Write a generic error handling routine.
16. How to copy text to the Windows clipboard and from it.
17. How can I call a Command button without clicking it?
18. Write a simple app with Encrypt and Decrypt buttons and Textbox where the user can enter text for encryption and decryption.
19. The Answer to question 17 is that u need to set the value property of command button to true
Siddharth
20. 16) How to copy text to the Windows clipboard and from it.
ans :
for Retreiving data from clipboard other then text
Clipboard.getData for other then text format data
for setting data other then text
for assigning data to clipboard other then text
Clipboard.setData for other then text format data
Clipboard.getText
Clipboard.SetText
viceversa
Siddharth
21. Answer for 11 Question : Set Text Box PasswordChar Property to *
Kalyani
22. Answer to 1st Question: Set Form StartUpPostion Property to 2-CenterScreen.
Answer to 13th and 14Th Questions :Use CreatePopupmenu API function .
Kalyani
23. LongValue = RGB(RedValue,GreenValue,BlueValue)
can convert RGB to long value
Manu
24. Hello to all
Some of the answers of Above questions are there at http://www11.brinkster.com/binoj/vbhowto.htm#
Kalyani
25. 1.
‘ Center form on the screen
formname.Left = Int(Screen.Width - formname.Width) / 2
formname.Top = Int(Screen.Height - formname.Height) / 2
odette
26. How do you center a form?
Set Form StartUpPostion Property to 2-CenterScreen
OR
Private Sub Form Load ()
Me. Top = Screen. Height / 2 - Me. Height / 2
Me. Left = Screen. Width / 2 - Me. Width / 2
End Sub
Sumesh
27. Can I send keystrokes to a DOS application?
AppActivate (”C:\windows\system32\cmd.exe”) ‘ Appilcation caption
SendKeys (”SA”) ’For sending one string
SendKeys “% ep”, 1’ For sending Clipboard data to Dos
Sumesh
28. Convert an RGB value to a long, or a long to RGB
RGB (210, 120, 34)
QBColor (2)
Sumesh
29. Implement smooth scrolling for either text, graphics or controls across a form.
Autoredraw = true
Sumesh
30. Implement some quick and easy encryption (can be something primitive).
Take string, convert each charter to hex.
get private key, get private key hexs added up.
Add cahracted hex and pvtkey hex.
Not it.
give a seperator and do out.
Reverse gives decoding as shown below
Private Sub Form_Load()
Dim A As String
Dim str As String
Dim str1 As String
Dim I As Long
Dim AscChar() As String
Dim hexArray() As Long
Dim pvtKey As String
Dim hexKey() As Long
Dim hexKeyVal As Long
Dim outstring As String
Dim strTmp() As String
Dim GetVal() As Long
Dim Decodedstr As String
ReDim AscChar(0)
ReDim hexArray(0)
ReDim hexKey(0)
str = “Sumesh” ‘ input string
pvtKey = “vrs” ‘ private key for encryption
For I = 1 To Len(pvtKey)
ReDim Preserve hexKey(I)
‘AscChar(I) = Mid(pvtKey, I, 1)
hexKey(I) = Asc(Mid(pvtKey, I, 1))
hexKeyVal = hexKeyVal + hexKey(I)
Next I
For I = 1 To Len(str)
ReDim Preserve AscChar(I)
ReDim Preserve hexArray(I)
AscChar(I) = Mid(str, I, 1)
hexArray(I) = Not (Asc(AscChar(I)) + hexKeyVal)
If outstring = “” Then
outstring = CStr(hexArray(I))
Else
outstring = outstring + “,” + CStr(hexArray(I))
End If
Next I
strTmp = Split(outstring, “,”)
ReDim GetVal(UBound(strTmp) + 1)
For I = 0 To UBound(strTmp)
GetVal(I) = Not (strTmp(I))
GetVal(I) = GetVal(I) - hexKeyVal
Decodedstr = Decodedstr + Chr$(GetVal(I))
Next I
MsgBox “Input string : ” + str + vbNewLine + “Encoded string : ” + outstring + vbNewLine + “Decoded string : ” + Decodedstr
End Sub
Sumesh
31. How do you use the Mouse OFF event?
Ole Drag drop
Sumesh
32. How do I call Windows Help files from a VB program?
Public Declare Function WinHelp Lib “user32″ Alias “WinHelpA” (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Any) As Long
Sumesh
33. How do I make text box that displays asterisks when the user types in data such as password?
Text1.Passwordchar =”*”
Sumesh
34. How do I create multi-column combo box?
Combo1.style = simple combo
Sumesh
35. How do I make a menu popup from a CommandButton
Call TrackMenuPopup defined in user32.dll, declaration follows :
Public Declare Function TrackPopupMenu Lib “user32″ (ByVal hMenu As Long, ByVal wFlags As Long, ByVal X As Long, ByVal Y As Long, ByVal nReserved As Long, ByVal hWnd As Long, lprc As Any) As Long
Sumesh
36. Write a generic error handling routine.
Public Sub GenericErrMsg(I As Long, B As String)
Dim A As String, I1 As Long
B = StrAnsi(B)
GTPRODUCT = “Sumesh’s new software”
Select Case I
Case 1
A = “Can’t load project: ” + B: I1 = 48
Case 2
A = “Can’t save project” + B: I1 = 48
Case 3
A = “Can’t create net hook ” + B: I1 = 48
Case 4
A = “Can’t find project file: ” + B: I1 = 48
Case 21
A = “Range Error: ” + B: I1 = 48
Case 22
A = “Can’t load Sumes font, default assumed.” + B: I1 = 48
Case 23
A = “Can’t exceed 25 characters.” + B: I1 = 48
Case 24
A = “Password can’t exceed 8 characters.” + B: I1 = 48
Case 101
A = “Already exists: ” + B: I1 = 48
End Select
MsgBox A, I1 Or MB_SYSTEMMODAL, GTPRODUCT
End Sub
Sumesh
37. What is the difference between ADO vs RDO ?
Shiraz
38. What is the difference between ActiveX Exe And Standard EXE ?
Tushar
39. what is called inprocess & outprocess,? explain the differnce
singanan
40. 1).The answer of first question is set form startup-position to center-owner or center-screen.
KingKalon
41. Ans 15). u just call this function. & u catch the compleate error Hierarchy very easily.
Public Function MakeLogFile(ByVal ErrorPosition As String) As String
Dim sFileName As String
Dim iFileNo As Integer
If ErrorPosition <> “” Then
sFileName = App.path & “\ErrorLogFile.txt”
iFileNo = FreeFile
Open sFileName For Append As #iFileNo
Print #iFileNo, “Error No = ” & Err.Number
Print #iFileNo, “Error Description = ” & Err.Description
Print #iFileNo, “ErrorPosition = “; ErrorPosition
Print #iFileNo, “Date = ” & Date
Print #iFileNo, “Time = ” & Time
Print #iFileNo, “”
Close #iFileNo
End If
End Function
if wants any more answers mail me at: kingkalon@yahoo.com
KingKalon
42. The answer for 17th question :
private sub command1_click()
msgbox(”Hello world”)
end sub
private sub Command2_click()
command1_click
end sub
Vidya
43. How do I make a menu popup from a CommandButton
Ans :
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu Menuname
End If
End Sub
By Jerrin
To solve your queries visit http://www.websamba.com/jerrin enter ur questions as feedback. I will reply as mail
Anonymous
44. How do I make a menu popup from a CommandButton
Ans :
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu Menuname
End If
End Sub
By Jerrin
To solve your queries visit http://www.websamba.com/jerrin enter ur questions as feedback. I will reply as mail
Jerrin
45. How do I make a menu popup from a CommandButton
Ans :
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu Menuname
End If
End Sub
By Jerrin
To solve your queries visit http://www.websamba.com/jerrin and enter ur questions as feedback. I will reply in mail .
Jerrin
46. How do I make a menu popup from a CommandButton
Ans :
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu Menuname
End If
End Sub
By Jerrin
To solve your queries visit http://www.websamba.com/jerrin and enter ur questions as feedback there. I will reply in mail .
Jerrin
47. Answers are to the point,
Still some of the answers are breath taking (since i am novice to this vb)
Sridhar.V
48. How to copy text to the Windows clipboard and from it.
Clipboard.SetData
and
Clipboard.GetData
Sumeshvr@hotmail.com
49. How can I call a Command button without clicking it?
RaiseEvent
Sumeshvr@hotmail.com
50. How do I create multi-column combo box?
VB6’s combo box doesn’t allow for multiple columns in its combo boxes.
If you want to display multiple columns you can concatenate the columns together
or create your own control
or by a third party combo box control
Judith
51. how many cookies are stored in server?
How to give the security in vb application and asp?
gulam mohamed
52. like ‘option explicit’ is there any thing like ‘option base..’ pls let me know.
and what does it mean in visual basic
amit jadhav
53. Option Base is to set the Index of the Array to start from 0 or 1.
Like option explicit.. declare “Option base 1″ at the top. now the array will start from Index 1.
By default the index starts from 0.
Anand
54. Multi Column Combobox - If you need a Multicolumn combobox.. the best suitable control in VB is ListView Control. This should fit your need.. which can display multi column and also the checkbox facility for each row.
Anand
55. Q- difference between RDO and ADO
A- ADO can access data from flat files as well as the databases,it is the encapsulation of DAO,RDO,OLE and hence called as OLE-DB technology.RDO follows a hierarchy model following its base objects rdoenvironment,rdoconnections,rdoresultset,rdoqueryobject which gives a way to manage multiple connections and multiple result set objects but is expensive to implement unwanted object persistence.
Reena
56. one can find good questions along with their answers over here :
http://www11.brinkster.com/binoj/vbhowto.htm#How%20to%20use%20Len%20function?
Reena
57. This is a suitable site, candidates like me.
Q. How do I know the caption-tip of menus in my MDI’s Status Bar? Like if I have a Menu:- File->Edit, as soon as the user move the mouse on this menu a description is shown in the Status Bar “Edit your tasks.”.
Please mail the answer at g_arora@hotmail.com
Thanks,
Gaurav Arora
Gaurav Arora
58. I wish to thank all those who have shared their knowlede, and it was of great help.
How do you detect if any one of the diffrent forms I have in an application is used ( either a keypress or a move movement).
I have done this by keeping a global flag and keeping a timer on each form (some of which are not child to the mdi form). I am sure there is a better way to deal with this.
Thanks
SP
shiburaj
59. How to trap the alt key in the text box?
jai
60. What is the difference between ADO vs RDO ?
ADO is most similar to RDO. ADO “flattens” the object model used by RDO, meaning that it contains fewer objects and more properties,methods and events.
kiran
61. To Trap the Alt Key in a TextBox you will probably have to make use of API’s in VB.
Nitin Shinde
Web Developer
http://www.websamba.com/nitinshinde
Nitin Shinde
62. 1. How to test a dll?
2. Two ways of creating objects.
3. How to optimise the SQL statement?
4. Diff types of Cursors, Locks
5. Diffrence of Proc & Fn in SQL Server
6. Microsoft recommended method of connection
7. Diff between left and right outer join
Sudheer
63. Great help for VB developers.Thanks for all those who share their knowledge.
sureshnanubala
64. i want to know about the different between rdo and ado.
different between dll and com
senthil
65. what is the difference between ado,rdo and dao????
babita
66. Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function SystemParametersInfo Lib “user32″ Alias “SystemParametersInfoA” (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As RECT, ByVal fuWinIni As Long) As Long
Private Const SPI_GETWORKAREA = 48
‘ Center the form taking the task bar
‘ into account.
Private Sub CenterForm(ByVal frm As Form)
Dim wa_info As RECT
Dim wa_wid As Single
Dim wa_hgt As Single
Dim wa_left As Single
Dim wa_top As Single
If SystemParametersInfo(SPI_GETWORKAREA, _
0, wa_info, 0) 0 _
Then
‘ We got the work area bounds.
‘ Center the form in the work area.
wa_wid = ScaleX(wa_info.Right, vbPixels, vbTwips)
wa_hgt = ScaleY(wa_info.Bottom, vbPixels, vbTwips)
wa_left = ScaleX(wa_info.Left, vbPixels, vbTwips)
wa_top = ScaleY(wa_info.Top, vbPixels, vbTwips)
Else
‘ We did not get the work area bounds.
‘ Center the form on the whole screen.
wa_wid = Screen.Width
wa_hgt = Screen.Height
End If
‘ Center the form.
frm.Move (wa_wid - Width + wa_left) / 2, _
(wa_hgt - Height + wa_top) / 2
End Sub
‘ Center the form.
Private Sub Form_Load()
‘ Make the form really big so it’s
‘ easy to see that it is centered.
Width = Screen.Width - 1440
Height = Screen.Height - 1440
‘ Center the form.
CenterForm Me
End Sub
rohit
67. “Option base ” is used to set the start index for an array.It must be defined at the top of the code in the declaration part.
e.g Option base 0
Yogi
68. Q. How to trap the Alt key in the TextBox ?
A. Use the KeyDown Event of the Text Box. The “Shift as integer” parameter in Keydown Event code holds the keycodes against the “Alt,Ctrl etc. keys).
Yogi

Your Title