Basic VB interview questions

A reader sent these in noting that these questions were used in his company for interviewing prospective VB programmers.

  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.
This entry was posted in VB. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

71 Comments on Basic VB interview questions

  1. Poornima
    Posted 5/27/2006 at 6:55 am | Permalink

    Answer for Qn. No. 41
    Each & Every textbox in VB , has the Event “Keydown” and from there you can trap the Alt Key.

    To Test this give a simple statement,
    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    MsgBox KeyCode
    End Sub

    If u press alt key on that text, u will get the result.

  2. shweta
    Posted 7/7/2006 at 3:12 am | Permalink

    Ans for Q. 1 we can center a from by setting its startup position property to center

  3. shweta
    Posted 7/7/2006 at 8:34 am | Permalink

    To make a menu popup from a CommandButton-
    U can use following link which has illustrated it.also u can get the code for menu at runtime.

    http://www.mvps.org/vbvision/_samples/TrackMouseEvent_Demo.zip

  4. shweta
    Posted 7/7/2006 at 8:36 am | Permalink

    Ans for Q 13-

    PopupMenu menuname

    ex. popupmenu mnufile

  5. shweta
    Posted 7/7/2006 at 8:38 am | Permalink

    Ans for Q.15-

    Public sub command_click()
    On error goto noerr
    .
    .
    code
    .
    noerr:
    msgbox Err.number & ” ” & err.description

    End Sub

  6. sumathi
    Posted 7/28/2006 at 12:16 am | Permalink

    for the 17th Question There is no value property for the command button,
    that is cancel property

  7. Dhandapani.S
    Posted 10/7/2006 at 7:09 am | Permalink

    17th Question : Command Buttons have Value property, When ever you execute the statement Cmd_Save.Value=true

    1. Cmd_Save_Click() event called and the statements are executed wihin the event.
    2. Usage of The Cancel property of a command button is : to execute code with in the command button when you press ‘Esc’ key:

    eg: Cmd_Save.Cancel = True ‘When you press ‘Esc’ Key the Cmd_Save_Click event executed

    3. Usage of The Default property of a command button is : to execute code with in the command button when you press ‘Enter’ or ‘Return’ Key:

    eg: Cmd_Save.Default = True ‘When you press ‘Enter’ or ‘Return’ Key the Cmd_Save_Click event executed

  8. Dhandapani.S
    Posted 10/13/2006 at 7:42 am | Permalink

    Ans 36. To register a ActiveX dll : run the command in dos window or RUN window

    regsvr [pathname\dllName.dll]

    to unregister
    regsvr/u [pathname\dllName.dll]

  9. SUGI
    Posted 10/26/2006 at 7:43 am | Permalink

    Ans for Q-18….
    Private Sub CmdDecrypt_Click()
    If Trim(TxtEncrypt.Text) = “” Then Exit Sub
    LblEncrypt = “Decrypted Text : ”
    TxtResult = M_Fn_EncryptDecrptPWD(Trim(TxtEncrypt.Text))
    End Sub

    Private Sub CmdEncrypt_Click()
    If Trim(TxtEncrypt.Text) = “” Then Exit Sub
    LblEncrypt = “Encrypted Text : ”
    TxtResult = M_Fn_EncryptDecrptPWD(Trim(TxtEncrypt.Text))
    End Sub

    Public Function M_Fn_EncryptDecrptPWD(CurPassword As String) As String
    Dim gfn_name As String
    On Error GoTo ERRPART:
    Dim intLength As Integer
    Dim iIndexPos As Integer
    Dim sSourceStr As String
    Dim sDecrptStr As String
    Dim sStrChar As String
    Dim iAscValue As Integer
    Dim iConvValue As Integer

    gfn_name = “M_Fn_EncryptDecrptPWD”

    sSourceStr = CurPassword

    intLength = Len(sSourceStr)

    If intLength = 0 Then
    M_Fn_EncryptDecrptPWD = “”
    Exit Function
    End If

    sDecrptStr = “”
    For iIndexPos = 1 To intLength
    sStrChar = Mid$(sSourceStr, iIndexPos, 1)
    iAscValue = Asc(sStrChar)
    iConvValue = iAscValue Xor 80
    sDecrptStr = sDecrptStr + Chr(iConvValue)
    Next iIndexPos

    M_Fn_EncryptDecrptPWD = sDecrptStr

    Exit Function
    ERRPART:
    MsgBox Err.Description & Space(2) & ” - ” & gfn_name, vbCritical, mg_sProductTitle

    ‘MsgBox Err.Description & Space(2) & gfn_name, vbCritical
    M_Fn_EncryptDecrptPWD = “”
    End Function

  10. Nilesh
    Posted 12/6/2006 at 6:23 am | Permalink

    forms Option statement
    OPtion Explicit - Variable Declaration
    Option base - Array lower bound
    Option compair -text comparing

  11. JRQ
    Posted 12/7/2006 at 12:28 pm | Permalink

    For the life of me, I can’t understand why do tech companies have this kind of interview.

    Should they focus more on problem solving skills than quiz applicants on things that they might not know off-hand but can be researched somewhere?

    They might unintentionally pick a “bookish” applicant instead of an applicant that understands “real life” issues better.

    In the long run, even an average programmer will eventually become proficient in coding for the intended software once he/she understands how the application works.

  12. shweta M
    Posted 1/9/2007 at 1:59 am | Permalink

    1. For displaying Help file here is the code:
    Private Declare Function WinHelp Lib “user32″ Alias “WinHelpA” (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long

    Private Const HELP_CONTENTS = 5
    Private Const HELP_FINDER = 11

    Private Sub Command1_Click()
    Dim lResult As Long
    Dim sHelpFile As String
    Dim lCommand As Long, lOption As Long
    sHelpFile = “windows.hlp”
    lCommand = HELP_CONTENTS
    lOption = 0
    lResult = WinHelp(Me.hwnd, sHelpFile, lCommand, lOption)
    End Sub

    2.Difference betn Activex EXE (out process server) & Actives DLL (inprocess server):
    ->DLL runs in the same space(memory) as that of application where as exe runs as a seperate process.
    ->hence using dll is faster compared to using exe

  13. BUJJI
    Posted 1/10/2007 at 1:08 am | Permalink

    what is the difference between dll and ocx control ?

  14. Zulfikar
    Posted 2/5/2007 at 3:52 pm | Permalink

    How to create ini file in VB, please tell me the simple method.

  15. sangeetha
    Posted 3/28/2007 at 11:19 am | Permalink

    How can i call a command button without clicking it?

  16. yogesh Sharma
    Posted 6/20/2007 at 5:08 am | Permalink

    Way To Get Connection String at your own:
    Steps:
    1) Create file in notepad as filename.txt leave it blank.
    2) Save As it {path]/filename.udl and exit the Notepad.
    3) Open the My Computer-> goto the ->file and just double Click.
    4) it Automatically open with the wizard that make your Connection task easy.
    5) open your file with Notepad.
    6) and you get the Connection String of any kind of server of Windows.

    Any Problem
    contact : yogihanu@yahoo.com

    Thanks

  17. Debabrata
    Posted 11/1/2007 at 11:13 pm | Permalink

    How to show a pregress bar on a VB form when a stored procedure is getting executed at the back-ground?

  18. prem
    Posted 1/20/2008 at 11:47 am | Permalink

    is there non event contrls?

  19. Posted 8/23/2008 at 12:32 pm | Permalink

    How do you center a form?
    Ans: its easy
    First you findout width and height of the screen
    the code for this is(use me or formname, me is nothing but active form)

    me.left=screen.width/2-me.width/2
    me.top=screen.height/2 -me.height/2

    place these two line of the code in form load event.

  20. Posted 8/23/2008 at 12:37 pm | Permalink

    Implement some quick and easy encryption (can be something primitive).
    ans:
    say you want to convert into encrypted format( not in orginal text, primitive)
    code:
    test=”Text to be converted”
    encry=”"
    for i=1 to len(test)
    encry=encry+chr(ASC((mid(test,i,1))+38)
    next i
    msgbox (encry)

  21. Prakash
    Posted 10/18/2008 at 8:15 am | Permalink

    Hi One And All,

    This is sample Code For Calling
    CommandButton Click Event Without manually user click.
    Ex:
    Private Sub Command1_Click()
    Msgbox “You Clicked Command button With _
    Out Manually Click”
    End Sub

    Ex: Call Command Button From Load Event
    Private Sub Form_Load
    Call Command1_Click
    End Sub

    Thank YOu

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

viagra online
cialis for sale
cialis 20mg
cialis online