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

VB Faqs

1. 3 main differences between flexgrid control and dbgrid control
2. ActiveX and Types of ActiveX Components in VB
3. Advantage of ActiveX Dll over Active Exe
4. Advantages of disconnected recordsets
5. Benefit of wrapping database calls into MTS transactions
6. Benefits of using MTS
7. Can database schema be changed with DAO, RDO or ADO?
8. Can you create a tabletype of recordset in Jet - connected ODBC database engine?
9. Constructors and distructors
10. Controls which do not have events
11. Default property of datacontrol
12. Define the scope of Public, Private, Friend procedures?
13. Describe Database Connection pooling relative to MTS
14. Describe: In of Process vs. Out of Process component. Which is faster?
15. Difference between a function and a subroutine, Dynaset and Snapshot,early and late binding, image and picture controls,Linked Object and Embedded Object,listbox and combo box,Listindex and Tabindex,modal and moduless window, Object and Class,Query unload and unload in form, Declaration and Instantiation an object?
16. Draw and explain Sequence Modal of DAO
17. How can objects on different threads communicate with one another?
18. How can you force new objects to be created on new threads?
19. How does a DCOM component know where to instantiate itself?
20. How to register a component?
21. How to set a shortcut key for label?
22. Kind of components can be used as DCOM servers
23. Name of the control used to call a windows application
24. Name the four different cursor and locking types in ADO and describe them briefly
25. Need of zorder method, no of controls in form, Property used to add a menus at runtime, Property used to count number of items in a combobox,resize a label control according to your caption.
26. Return value of callback function, The need of tabindex property
27. Thread pool and management of threads within a thread pool
28. To set the command button for ESC, Which property needs to be changed?
29. Type Library and what is it’s purpose?
30. Types of system controls, container objects, combo box
31. Under the ADO Command Object, what collection is responsible for input to stored procedures?
32. VB and Object Oriented Programming
33. What are the ADO objects? Explain them.
34. What are the different compatibility types when we create a COM component?
35. What do ByVal and ByRef mean and which is the default?
36. What does Option Explicit refer to?
37. What does the Implements statement do?
38. What is OLE and DDE? Explain.
39. What is the difference between Msgbox Statement and MsgboxQ function?
40. What keyword is associated with raising system level events in VB?
41. What methods are called from the ObjectContext object to inform MTS that the transaction was successful or unsuccessful?
42. What types of data access have you used.
43. What was introduced to Visual Basic to allow the use of Callback Functions?
44. Which controls can not be placed in MDI?
45. Which controls have refresh method, clear method
46. Which Property is used to compress a image in image control?
47. Which property of menu cannot be set at run time?
48. Which property of textbox cannot be changed at runtime and What’s the maximum size of a textbox?
49. Which tool is used to configure the port range and protocols for DCOM communications?
50. Question asked to me in interview:
1) Assume i have created a dll in c++ which doesn’t have any class. It only have one function. How can i call that function in VB.
2) What is control array and maximum limit of control array.
3) Which one you will prefer for working with databases - OLEDB or ADO’s and why.
4) What is the difference between Active X DLL & Active X Exe.
comment by Pramod
51. What are Disconnected Recordsets? Advantages?
The ADO has the ability to work offline with recordsets.
The ADO Maintains the informations such as Database name,Server in which the database reside,username and password etc…After loacting a recordset it disconnects and work with them and finally send it back to the database by re-establishing the connection by making use of the already stored informations about the connetion and the database.
Advantage: Minimizes the Load on the SErver
1.what is MTS??
2.Types of ActiveX Objects and Components??? is there any difference between both these???
comment by Prema
52. respected Sir/madam
i am jitendra Singh Bhaskar.Student of B.Sc(I.T) in Sikkim Manipal University.
i have aproblem with some question of Visual basic .I am not able to define it.
please solve my question.
i am very glad to you
thanking you
jitendra singh bhaskar
Q-Write an event procedure to check whether the given string is Palindrome or not.
Q-Explain the different control structures by giving syntax and one suitable example for each:
1)For…Next Loop.
2)Select Case Statement
3)Do While Loop
comment by Jitendra Singh Bhaskar
53. Respected Sir/Madam,i have a doubt from VB .
1.what is the purpose of Visual Source safe in MicroSoft Visual Studio?
2.What is the difference between datagrid and flex grid control?
3.Explain MTS?
4.What is the different between crystal report and data report?
5.Need of zorder method, no of controls in form, Property used to add a menus at runtime, Property used to count number of items in a combobox,resize a label control according to your caption.
comment by SHAILA
54. Respected Sir/Madam,i have a doubt from VB .
1.what is the purpose of Visual Source safe in MicroSoft Visual Studio?
2.What is the difference between datagrid and flex grid control?
3.Explain MTS?
4.What is the different between crystal report and data report?
5.Need of zorder method, no of controls in form, Property used to add a menus at runtime, Property used to count number of items in a combobox,resize a label control according to your caption.
comment by rakesh kumar
55. respected sir
i have some question
1. what is difference betn db grid and flexgrid
2.how to call astored procedure in ado.
3.what is query unload
4.instancing property of dll.
comment by rakesh kumar

VB Questions

  1. How do you represent your menu description in the status Bbr of your MDI? So that when I move the mouse over menu option, the description is shown in appropriate status bar?
  2. How would you make a program which scans a bar code and perform action depending on the bar code value?
  3. What is the difference between Windows programming and database programming?
  4. How do you combine a number of ActiveX control, which you developed, into a single app?
  5. How do you interact with the hardware level within your VB code if no APIs or documentation is supplied?

6. Hi,

Difference between Windows Programming and Database Programming
Windows Programming
——————-
Windows programming is depends on designing windows based application software which is called Graphical user interface(GUI).
Database Programming
——————–
Database programming are related to application programme for which we will have front-end and back-end. An application that are developed with the help of connecting database, RDBMS like Oracle,SQL server,windows access,Sybase,etc are known as database application.

7. How do you represent your menu description in the status Bbr of your MDI? So that when I move the mouse over menu option, the description is shown in appropriate status bar?
How would you make a program which scans a bar code and perform action depending on the bar code value?
How do you combine a number of ActiveX control, which you developed, into a single app?
How do you interact with the hardware level within your VB code if no APIs or documentation is supplied?

8. How Many Control can Placed in VB Form

comment by Kumar

9. Ans 2
for displaying the text in status bar subclass the mdi window and in windowproc look for WM_MENUSELECT message and display text as per the id

Ans 3
the maximum number of controls on a form are 256 however the limit can be bypassed by using control arrays . thus the total limit can be 256 * 32000

comment by thencoder

Your Title