Question about Microsoft Visual Basic 6.0 for PC

1 Answer

Program not working

I click on my command button on VB and a error message came up saying Type mismatch and highlighted the private sub part

Posted by on

  • Stephen McGloughlin
    Stephen McGloughlin May 11, 2010

    Can't answer your question without more info. Post your code here and give the precise text or a screenshot of the error and any line numbers it may point to, and I'm sure we can find an answer for you. Without seeing your code we cannot evaluate it and determine where it is broken.

×

1 Answer

  • Level 1:

    An expert who has achieved level 1.

    Hot-Shot:

    An expert who has answered 20 questions.

    Corporal:

    An expert that hasĀ over 10 points.

    Mayor:

    An expert whose answer gotĀ voted for 2 times.

  • Contributor
  • 46 Answers

Type mismatch is caused by trying to use a variable defeined as one type to store another type of data. For example a variable that is integer but you try to set it to a letter.
In VB.net this can be caused by a line like this:
textbox="hello"
when it should be
textbox.text="hello"
see if you have that sort of mistake.

Posted on Aug 28, 2009

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

How to disable command button in visual basic


  • tep 1 Open Visual Basic and select "Standard Exe" to create a new project.
  • Step 2 Add a button by clicking the square button tool on the right, and then clicking and dragging in the main window.
  • Step 3 Click the button once to open the "Properties" window on the right. Select the "(Name)" property, and type "myCmdButton" as the name.
  • Step 4 Double-click the button to open up the code-view window. Type the following in the white space under "Private Sub myCmdButton_Click()":
    myCmdButton.enabled = False;
  • Step 5 Click the blue "Run" button on the top toolbar of Visual Basic. Because you set enabled to "false" in the previous step, you will see your button grayed out, and nothing will happen when you click it.
  • Jul 07, 2010 | Microsoft Computers & Internet

    1 Answer

    Can you make an internet browser with microsoft visual basic 2008?


    yes you can below you have one option:
    Create a new project, and then go to "Project" on the menu.
    Click components as shown in the following image.
    Find the component "Microsoft Internet Controls," check it, and click "Apply" and then "Close."
    Click the icon that was just added in the tools window, and draw a large sized window with it. This is going to be where you view webpages through your browser, so don't make it small, but leave room for buttons and other accessories.
    Make a textbox, this will be your URL bar where you type in the address of the website you want to see.
    Make four command buttons, these are going to be your Go, Back, Forward, and Refresh buttons, change the captions accordingly, and name each of them Cmdgo, Cmdback, CmdForward, and CmdRefresh.
    Now, here's the coding part. This is all it takes to make your webbrowser working:
    Private Sub cmdback_Click()
    WebBrowser1.GoBack
    End Sub
    Makes the back button go backwards, pretty much self explanatory:
    Private Sub Cmdforward_Click()
    WebBrowser1.GoForward
    End Sub
    Same concept, except this time the webbrowser goes forward:
    Private Sub cmdgo_Click()
    WebBrowser1.Navigate (Text1.Text)
    End Sub
    Makes your webbrowser go to the URL in your text box:
    Private Sub cmdrefresh_Click()
    WebBrowser1.Refresh
    End Sub
    Makes your web browser refresh:
    Private Sub Form_Load()
    WebBrowser1.Navigate ("http://yahoo.com")
    End Sub
    The URL shows your homepage, change it to http://google.com or whatever your usual homepage you would like to be.
    Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
    Text1.Text = (WebBrowser1.LocationURL)
    Form1.Caption = (WebBrowser1.LocationName)
    End Sub

    Jan 15, 2010 | Computers & Internet

    1 Answer

    Program code that can light a bulb using vb


    You can do it a couple of ways, but this would probably be the shortest. Realize this depends on what forms you're qualifying for the pictures.

    1. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    2. '
    3. PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
    4. End Sub
    5. Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    6. '
    7. PictureBox1.Image = Image.FromFile("C:\BulbOn.jpg")
    8. End Sub
    9. Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
    10. '
    11. PictureBox1.Image = Image.FromFile("C:\BulbOff.jpg")
    12. End Sub

    Jan 05, 2010 | Microsoft Step by Step Visual Basic 6.0...

    1 Answer

    How to connect vb with ms access


    se Adodc OR Even better.. ADODB. for this you need to get MDAC fromMicrosoft free download.(check under project_References- Microsoft DataActiveX objects.. the current no is 2.8. if it is not there download invb directory.

    next, you can learn about creating a DSN from control panel, ODBC. onceyou learn this, connection becomes a piece of cake. get some free vbtutoriasl from WWW.

    then

    you need to use DAO or ADO to connect to the database. better study both but since ADO is current, i am showing that code.
    under Menu Project_References, put a check mark on Microsoft ActiveXData Objects latest version (though it works for all, currently 2.8with sp pack 1 ).

    at the general declarations:
    dim conn as adodb.connection, rec as adodb.recordset, esql as string,esql1 as string
    Private Function connect()
    Set rec = New ADODB.Recordset
    Set conn = New ADODB.Connection
    esql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "D:VBDesigndhana2.mdb" & ";Persist Security Info=False"
    'here you put the correct path of your mdb file. and check if you have jet 4.0

    conn.Open (esql), , , 0
    End Function

    private sub form_Load()
    connect
    end sub
    and for adding records:
    say let us say you have 3 fields. then have 3 textboxes and 1 command button on the form.

    private command1_click()
    esql1="select * from Yourtablename"
    rec.open(esql1),conn,, adOpenDynamic, adLockOptimistic
    rec.AddNew
    rec.Fields(0) = text1.Text
    rec.Fields(1) = Text2.text
    rec.Fields(2) = text3.text
    ' you need to check if in your access table design you have Allowed Zero length .. set it to Yes for all text fields.
    rec.update
    if not rec.eof then rec.movenext
    rec.close
    conn.close
    set conn to nothing
    end sub

    this will add new records to access table from VB.
    ' for picture store the full path of the path and the picture file nameint the text field. and in the picturebox of VB form for viewingrecords again you need ADO or ADODC and here you code:picture1.picture=Loadpicture(rec.fields(3) ' depending on where thepicture field is located. you need to make a few trials.
    under Menu Project_References, put a check mark on Microsoft ActiveXData Objects latest version (though it works for all, currently 2.8with sp pack 1 ).

    at the general declarations:
    dim conn as adodb.connection, rec as adodb.recordset, esql as string,esql1 as string

    Private Function connect()
    Set rec = New ADODB.Recordset
    Set conn = New ADODB.Connection
    esql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "D:VBDesigndhana2.mdb" & ";Persist Security Info=False"
    'here you put the correct path of your mdb file. and check if you have jet 4.0

    conn.Open (esql), , , 0
    End Function

    private sub form_Load()
    connect
    end sub

    and for accessing records:

    private command1_click()
    esql1="select * from Yourtablename where id =" & val(text1) ' for integers

    esql1="select * from Yourtablename where name=" & "'" & text1 & "'" ' for string

    rec.open(esql1),conn, adOpenstatic, adLockreadonly

    label1.caption =rec.Fields(0)
    label2.caption= rec.Fields(1)
    label3.caption= rec.Fields(2)
    ' you need to check if in your access table design you have Allowed Zero length .. set it to Yes for all text fields.

    rec.close
    conn.close
    set conn to nothing
    end sub


    ' similarly there are routines to ADD, Delete, Edit, View etc.

    Feb 26, 2009 | Computers & Internet

    1 Answer

    An example of visual basic program


    Visual Basic (VB) is the thrid generation event-driven programming language and integrated development enviorment (IDE) from Microsoft for its COMprogramming model. VB is also considered a relatively easy to learn anduse programming language, because of its graphical development featuresand BASIC heritage.
    Here is an example of a code that displays a message box "Hello, World!"
    as the program runs:

    Private
    Sub Form_Load()
    MsgBox "Hello, World!"
    End Sub

    simply making duplicated lines of text and changing the words in the
    speech marks can draw a different text and ammounts.
    For example:

    Private
    Sub Form_Load()
    MsgBox "Welcome, blue_skies61!"
    MsgBox "My name is Siwek06!"
    End Sub

    you can also bold the text by puting this line before a text:

    Sub SetFontBold()

    Overall i think this is a easy language to learn.
    Go on to microsoft.com help center, or the forums to learn more.


    Feb 23, 2009 | Visual Land V-Touch Digital Media Player

    1 Answer

    What is the program code to shutdown the pc in visual basic


    I was wondering if someone could help me to convert this vb6 code to be used
    in VB.net. It basically allows you to call the subs at the bottom to logoff
    shutdown and restart the pc (By force if necessary). Any help is greatly
    appreciated.

    Private Const EWX_LOGOFF = 0
    Private Const EWX_SHUTDOWN = 1
    Private Const EWX_REBOOT = 2
    Private Const EWX_FORCE = 4
    Private Const TOKEN_ADJUST_PRIVILEGES = &H20
    Private Const TOKEN_QUERY = &H8
    Private Const SE_PRIVILEGE_ENABLED = &H2
    Private Const ANYSIZE_ARRAY = 1
    Private Const VER_PLATFORM_WIN32_NT = 2

    Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
    End Type

    Public Type LUID
    LowPart As Long
    HighPart As Long
    End Type

    Public Type LUID_AND_ATTRIBUTES
    pLuid As LUID
    Attributes As Long
    End Type

    Public Type TOKEN_PRIVILEGES
    PrivilegeCount As Long
    Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
    End Type

    Private Declare Function GetCurrentProcess Lib "kernel32.dll" () As Long
    Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal
    ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As
    Long
    Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias
    "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As
    String, lpLuid As LUID) As Long
    Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal
    TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As
    TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As
    TOKEN_PRIVILEGES, ReturnLength As Long) As Long
    Private Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As
    Long, ByVal dwReserved As Long) As Long
    Private Declare Function GetVersionEx Lib "kernel32.dll" Alias
    "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long

    Private Sub EnableShutDown()
    Dim hProc As Long
    Dim hToken As Long
    Dim mLUID As LUID
    Dim mPriv As TOKEN_PRIVILEGES
    Dim mNewPriv As TOKEN_PRIVILEGES

    hProc = GetCurrentProcess()
    OpenProcessToken hProc, TOKEN_ADJUST_PRIVILEGES + TOKEN_QUERY, hToken
    LookupPrivilegeValue "", "SeShutdownPrivilege", mLUID
    mPriv.PrivilegeCount = 1
    mPriv.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
    mPriv.Privileges(0).pLuid = mLUID
    AdjustTokenPrivileges hToken, False, mPriv, 4 + (12 *
    mPriv.PrivilegeCount), mNewPriv, 4 + (12 * mNewPriv.PrivilegeCount)
    End Sub

    Public Sub ShutDownNT(Force As Boolean)
    Dim Ret As Long
    Dim flags As Long

    flags = EWX_SHUTDOWN
    If Force Then flags = flags + EWX_FORCE
    EnableShutDown
    ExitWindowsEx flags, 0
    End Sub

    Public Sub RebootNT(Force As Boolean)
    Dim Ret As Long
    Dim flags As Long

    flags = EWX_REBOOT
    If Force Then flags = flags + EWX_FORCE
    EnableShutDown
    ExitWindowsEx flags, 0
    End Sub

    Public Sub LogOffNT(Force As Boolean)
    Dim Ret As Long
    Dim flags As Long

    flags = EWX_LOGOFF
    If Force Then flags = flags + EWX_FORCE
    ExitWindowsEx flags, 0
    End Sub

    Jan 01, 2009 | Microsoft Windows XP Professional With...

    1 Answer

    Type mismatch in MSFlexGrid Control


    type mismatch error occours when there is a mismatch between the value which you are trying to assign to a variable which is dimensioned to store values of another, first you check if the datatypes match each other by applying the break.

    Dec 19, 2008 | Microsoft Visual Basic 6.0 for PC

    1 Answer

    Access-VB


    Use this line below:

    Private Sub CommandButton_Click()

    Dim NumericValue as Integer
    Dim StringValue as String

    NumericValue = CInt(TextField1)
    StringValue = TextField2

    DoCmd.RunSQL "INSERT INTO NameOfTable ( [FieldName1], [FieldName2]) VALUES (" & NumericValue & " , '" & StringValue & "');"

    EndSub

    I Hope this work for you... God Bless

    Jul 16, 2008 | Microsoft Office Access 2003 (077-02871)...

    2 Answers

    About guidence


    i still not solved the problem

    Apr 18, 2008 | Computers & Internet

    1 Answer

    Password


    Hello, if you are using a vb program, i know a code that will allow you to make a password protect your programs. But you are prompt to enter it in every time you start the program.
    Private Sub Form_Load()
    passwordbox = InputBox("Please Enter Key")
    If passwordbox = "Put Your Password Here!" Then
    MsgBox "Welcome!"
    Else: MsgBox "You have entered the wrong password"
    Unload Me
    End If
    End Sub
    You can try this. Hope this can help you in some way :)

    Feb 29, 2008 | Computers & Internet

    Not finding what you are looking for?
    Microsoft Visual Basic 6.0 for PC Logo

    Related Topics:

    108 people viewed this question

    Ask a Question

    Usually answered in minutes!

    Top Microsoft Computers & Internet Experts

    micky dee

    Level 3 Expert

    2644 Answers

    Les Dickinson
    Les Dickinson

    Level 3 Expert

    18381 Answers

    Brian Sullivan
    Brian Sullivan

    Level 3 Expert

    27725 Answers

    Are you a Microsoft Computer and Internet Expert? Answer questions, earn points and help others

    Answer questions

    Manuals & User Guides

    Loading...