Where is my wrong in this code




I'm trying to write my first code in VBNet, But I got the bluw line under the word " answer" in the last line.

Here is the code:
[color=#3333FF]Public Class [/color] Form1 [color=#3333FF]Private Sub [/color] Button1_Click([color=#3333FF]ByVal[/color] sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click [color=#3333FF]Dim[/color] number1 [color=#3333FF]As Integer[/color] [color=#3333FF]Dim[/color] number2 [color=#3333FF]As Integer[/color] [color=#3333FF]Dim[/color] answer [color=#3333FF]As Integer[/color] number1 = 3 number2 = 5 answer = number1 + number2 TextBox1.Text = [color=#FF0000][u]answer[/u][/color] [color=#3333FF]End Sub End Class[/color]

I follow the tutorial in homeandlearn.co.uk

Please help to Understand my Error.

the best
Posted On: Monday 24th of December 2012 01:09:10 AM Total Views:  265
View Complete with Replies

RELATED TOPICS OF Visual Basic PROGRAMMING LANGUAGE




Visual Basic MS Comm Problem

Hi can you help me with my problem...I have interfaced VB6 to my hardware which will. VB6 will then get input from the hardware...my hardware will transmit data everytime a text message is received through a GSM Module... My problem is when i show the transmitted data in a textbox then clearing the textbox for another input... if I clear the text box with a txtTerm = "" the output will be a the complete text message, sometimes a part of the message. this is my code within the OnComm event Private Static Sub MSComm1_OnComm() Dim EVMsg$ Dim ERMsg$ Dim StrMain As String Dim StrBuff As Variant Dim CpNo As String Dim Code As String Dim LockNo As String Dim i As Integer ' Branch according to the CommEvent property. Select Case MSComm1.CommEvent ' Event messages. Case comEvReceive Dim Buffer As Variant Buffer = MSComm1.Input Debug.Print "Receive - " & StrConv(Buffer, vbUnicode) ShowData txtTerm, (StrConv(Buffer, vbUnicode)) 'my mirror to see if the correct message is received StrMain = txtTerm Text1.Text = StrMain 'my mirror to see what is received by Strmain If Len(StrMain) > 15 Then CpNo = Mid(StrMain, 35, 12) Code = Mid(StrMain, 78, 4) LockNo = Mid(StrMain, 76, 2) Text2.Text = CpNo Text3.Text = Code Text4.Text = LockNo Do Until Data1.Recordset.EOF If Data1.Recordset.Fields("LockerNo") = LockNo Then If Data1.Recordset.Fields("Cellphone") = CpNo And Data1.Recordset.Fields("Passcode") = Code Then MSComm1.Output = LockNo GoTo x End If Else Data1.Recordset.MoveNext End If Loop Data1.Refresh ElseIf Len(StrMain) < 15 Then Data1.Refresh Code = Mid(StrMain, 3, 4) LockNo = Mid(StrMain, 1, 2) Text3.Text = Code Text4.Text = LockNo Do Until Data1.Recordset.EOF If Data1.Recordset.Fields("LockerNo") = LockNo And Data1.Recordset.Fields("Passcode") = Code Then MSComm1.Output = LockNo MsgBox "Locker No at Passcode Ayos!" GoTo x Else Data1.Recordset.MoveNext End If Loop Data1.Refresh End If x: txtTerm = "" 'my way of clearing the textbox Case comEvSend Case comEvCTS EVMsg$ = "Change in CTS Detected" Case comEvDSR EVMsg$ = "Change in DSR Detected" Case comEvCD EVMsg$ = "Change in CD Detected" Case comEvRing EVMsg$ = "The Phone is Ringing" Case comEvEOF EVMsg$ = "End of File Detected" ' Error messages. Case comBreak ERMsg$ = "Break Received" Case comCDTO ERMsg$ = "Carrier Detect Timeout" Case comCTSTO ERMsg$ = "CTS Timeout" Case comDCB ERMsg$ = "Error retrieving DCB" Case comDSRTO ERMsg$ = "DSR Timeout" Case comFrame ERMsg$ = "Framing Error" Case comOverrun ERMsg$ = "Overrun Error" Case comRxOver ERMsg$ = "Receive Buffer Overflow" Case comRxParity ERMsg$ = "Parity Error" Case comTxFull ERMsg$ = "Transmit Buffer Full" Case Else ERMsg$ = "Unknown error or event" End Select Please post your comments about my code and if there are any errors in there
VIEWS ON THIS POST

60

Posted on:

Saturday 10th November 2012
View Replies!

Help with package and deployment wizard Error

When I run Package and Deployment Wizard, I don't get very far and then I get this error: Unexpected error number 429 has occured. ActiveX component cant create object. Can someone help me finnish packaging my program...
VIEWS ON THIS POST

86

Posted on:

Sunday 11th November 2012
View Replies!

data report

In a datareport I have a parent-child rel.ship and thats specified in the data environment commands. Works fine. But I want to set the datasource of the datareport by 'hand'. How do I specify the sql statement I get ...
VIEWS ON THIS POST

118

Posted on:

Sunday 11th November 2012
View Replies!

newbie: VB6 and Named Arguments

G'day , In VB6 I can create a reference to wscript.exe, and refer to the symbols therein, but can't seem to connect to any of them, e.g. IHost.IWSHNamedArguments_Class. Is there any way of getting access to the Named and Unnamed ...
VIEWS ON THIS POST

115

Posted on:

Monday 12th November 2012
View Replies!

What's wrong with MS Chart?

Hi I need to do a lot of chart work (ie pie charts, graphs, etc) in my vb6 app and I've noticed that quite a few don't use the built-in MS Chart component. Is there any reason It seems ...
VIEWS ON THIS POST

98

Posted on:

Thursday 15th November 2012
View Replies!

Deleting records from DAO recordset

Hi , I'm using the following code to delete one or more records from a DAO recordset. The code is working but I was wondering if I need to Update the recordset with: rsDel.Update Public Function DelRecs(Lstview As ListView, sEntity ...
VIEWS ON THIS POST

95

Posted on:

Thursday 15th November 2012
View Replies!

ctrl+alt+del

Is there a way to block or intercept ctrl+alt+del...
VIEWS ON THIS POST

70

Posted on:

Thursday 15th November 2012
View Replies!

7204317 CD-R, DVD R, DVD CASES LOWEST PRICE! 72

media4sale.com offers innovative and quality media, CD/DVD packaging and other computer accessories at the best prices. We pride ourselves in service, quality and commitment and are certain that our standards will exceed expectations. http://www.media4sale.com Media4Sale.com...
VIEWS ON THIS POST

55

Posted on:

Thursday 15th November 2012
View Replies!

Disable key-response in list boxes

Have a couple of list boxes in my program where the user can press a hot key to perform an action on the currently selected item in the list box, using the list box keypress event. So far so good ...
VIEWS ON THIS POST

168

Posted on:

Tuesday 20th November 2012
View Replies!

Converting a one char string to integer

Hi , How does one convert a binary data in a string to integer data I am using RB as a GUI to an embedded micro that sends 8 bit binary data down a serial port. AFAIK the serial port ...
VIEWS ON THIS POST

78

Posted on:

Tuesday 20th November 2012
View Replies!

DataReport 2

How to write informations from database in Page Header section like in Detal section of DataReport...
VIEWS ON THIS POST

62

Posted on:

Tuesday 20th November 2012
View Replies!

Copy locked files in Windows

Hi all. I would like to know how to copy files in Visual Basic 6 under Windows 2000 and XP when those files are locked because they are in use. I believe it has something to do with Volume Shadow ...
VIEWS ON THIS POST

93

Posted on:

Tuesday 20th November 2012
View Replies!

Send Email from MS Access DB using CDO

, I used to automatically send emails from my MS Access database using MS Outlook. However my company does not support outlook so I have to look at another way of sending emails. I found that I can use something ...
VIEWS ON THIS POST

82

Posted on:

Tuesday 20th November 2012
View Replies!

Hiding Data, Algorithms in Compiled Application

I have some hard coded data and some algortithums which are intially created as text strings, some within the open event of the program, and some within methods. The information within the data and the algorithums are licensed from another ...
VIEWS ON THIS POST

71

Posted on:

Tuesday 20th November 2012
View Replies!

Room Reservation

Hi , I am looking to design a visual basic program which stores information of rooms and allows people to reserve them for a certain date and time. Sounds simple enough but I don't really know if visual basic is ...
VIEWS ON THIS POST

107

Posted on:

Tuesday 20th November 2012
View Replies!

MySql server and .Net

Will a .NET application run on a MySQL server I know I can access MySQL tables by using the leDbDataAdapter, but will the server handle the .Net aspx and ado code Must the server have IIS installed Also, I'd like ...
VIEWS ON THIS POST

124

Posted on:

Tuesday 20th November 2012
View Replies!

ADO-Access Syntax error

Private Sub Form_Load() Adodc1.Recordset.Close Adodc1.Recordset.Source = "select * from user" Adodc1.Recordset.Open Set DataGrid1.DataSource = Adodc1 DataGrid1.ReBind End Sub When i run the program it show me msgbox Run-time error '-2147217900 (8004Je14)': [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause. ...
VIEWS ON THIS POST

175

Posted on:

Wednesday 21st November 2012
View Replies!

Set enable property for all items on a SSTAB control

, In one of my projects i use a SSTAB object with a view controls on it (textboxes and a checkbox). I want to set the enable property for all the controls on the SSTAB object to FALSE. Not the ...
VIEWS ON THIS POST

147

Posted on:

Wednesday 21st November 2012
View Replies!

Can I somehow convert a VB(A) Access program into VisualBasic .NET program ?

I have a rather old VisualBasic program which is included inside an Access *.mdb database. So I guess it is an VisualBasic and not and VBA program. Can I somehow automatically convert it into a VisualBasic program outside of Access ...
VIEWS ON THIS POST

170

Posted on:

Monday 26th November 2012
View Replies!

ZEBRA TLP2844

HI ALL my label is 2"" W by 1" H N D20 R225,50 A1,10,0,1,1,1,N,"Abcdefg Hijklmn" B1,30,0,3,2,3,80,N,"12345678901" A2,120,0,1,1,1,N,"11987654321" P and 2 blank labels are spooled out. how do i stop spooling immediately after the print command N does`nt refresh . and ...
VIEWS ON THIS POST

58

Posted on:

Monday 26th November 2012
View Replies!

How do i make a windows shell for school this is my project

im new to this forum and i have a project for school, what i need is how to make a desktop like windows with a start menu, and how do i make the icons move and be able to move them, i know you have to us a listbox but i just dont know how to us it to make a desktop i gess what im asking for is how to make a fake operating system, should i us visual basic 6.0 for this or c++ i only know how to us visual basic 6.0 just starting it so im a newbe, i know the basics, and i when to planet sourc code and foun a some but know of them have what im looking for, this just a project i need for school so please help me just to get started
VIEWS ON THIS POST

155

Posted on:

Wednesday 28th November 2012
View Replies!

Edit and SaVE Button

Public Class Client Private m_FirstName As String Private m_LastName As String Private m_AccountNumber As Integer Private m_Balance As Decimal Public Sub New(ByVal FirstName As String, ByVal LastName As String, ByVal AccountNumber As Integer, ByVal Balance As Decimal) Me.First = FirstName Me.Last = LastName Me.Account = AccountNumber Me.Balance = Balance End Sub Public Property First() As String Get Return m_FirstName End Get Set(ByVal value As String) m_FirstName = value End Set End Property Public Property Last() As String Get Return m_LastName End Get Set(ByVal value As String) m_LastName = value End Set End Property Public Property Account() As Integer Get Return m_AccountNumber End Get Set(ByVal value As Integer) If value < 0 Then m_AccountNumber = 0 Else m_AccountNumber = value End If End Set End Property Public Property Balance() As Decimal Get Return m_Balance End Get Set(ByVal value As Decimal) m_Balance = value End Set End Property End Class Admin Edit: Please use code tags when posting your code. Code tags are used like so =>
VIEWS ON THIS POST

61

Posted on:

Wednesday 28th November 2012
View Replies!

Print DataReport

expert VB..i neeed help...i want to print may datareport.and i using two data report.the info that i import is from diference table of database in acess.this is the code If DataEnvironment1.rsCommand1.State Then DataEnvironment1.rsCommand1.Close End If DataEnvironment1.Command1 Combo8.Text, DTPicker3.Value, DTPicker2.Value DataReport1.Show End If and also.i want to know how to open file from data grid.i have want coding but it debug. the code is If File1.FileName = "" Then MsgBox "Please select directory and file name", vbExclamation, "Missing" Else Call ShellExecute(hWnd, "Open", DataGrid1.columms & "\" & DataGrid1.columms, "", App.Path, 1) End If please help.... This post has been edited by macosxnerd101: 08 April 2011 - 10:08 AM Reason for edit:: Added code tags and split from necro.
VIEWS ON THIS POST

46

Posted on:

Wednesday 28th November 2012
View Replies!

designing my application in vb

hello, what are the ocx controls should i use to make my vb application look well. im not asking for a copy, but all im asking is you can help me in designing my form.
VIEWS ON THIS POST

108

Posted on:

Wednesday 28th November 2012
View Replies!

Odd even calculator

Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click ' displays the odd and even numbers between two integers Dim intNum1 As Integer Dim intNum2 As Integer Dim intOdd As Integer Dim intEven As Integer Integer.TryParse(txtNum1.Text, intNum1) Integer.TryParse(txtNum2.Text, intNum2) For counter As Integer = intNum1 To intNum2 If (intNum1) Mod 2 0 Then lstOdd.Text = lstOdd.Text & intNum1.ToString & vbNewLine intNum1 = intNum1 + 1 Else lstEven.Text = lstEven.Text & intNum1.ToString & vbNewLine intNum1 = intNum1 + 1 End If Next counter End Sub End Class
VIEWS ON THIS POST

118

Posted on:

Wednesday 28th November 2012
View Replies!

using left$,right, and Mid$

what is the vb code of left$,rigth$ and mid$ if u put different functions like CAR, getting the first letter inside the parenthesis.
VIEWS ON THIS POST

134

Posted on:

Wednesday 28th November 2012
View Replies!

Access Search

Hi I am new to Visual Basic, so this might come off as a pretty simple question. I am currently working on an access database and I have a search form that has 3 fields with a search button that is linked to a search results form. I dont want the search button to work if there is no data entered into any of the 3 fields. I want it to only work if there is at least one field entered in. So far this is all I have come up with and haven't had much luck. Private Sub Search_Click() If (IATSID = Empty) And (SystemName = Empty) And (SystemAcronym = Empty) Then Else DoCmd.OpenForm "SearchResults" Form_SearchResults.Requery End If End Sub I don't really have any idea what to put after the then statement to make the search go null. Any input would be appreciated.
VIEWS ON THIS POST

53

Posted on:

Wednesday 28th November 2012
View Replies!

vb6 import excel data where there is no header

I have several spreadsheets to import. The header in some columns are in row 1, some in row 2 and some in row 3. I need to build a where clause to get the rows where the data in column 1 is not null. Column 1 is one of the columns where the header text is not in row 1. I can connect to the spreadsheet(ado) and get data. Connection info below: Set oXLWB = oXLApp.Workbooks.Open(filePath) Set eRange = LastCell(oXLWB.Worksheets(1)) connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & filePath & "';Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1;"";" cn.Open connString I just need to be able to create the where clause. It would be something like this: sql = "select * from [SomeCity$A6:B" & eRange.Row & "] where (ID IS NOT NULL)" however, ID is in row 3. Not the header row. Can someone help with the where clause
VIEWS ON THIS POST

172

Posted on:

Wednesday 28th November 2012
View Replies!

Connecting forms in VB

I was hoping you could help me with this.. I'm making a program for a society's library and there will be two forms (book form holding all the information and allowing librarian to browse through all the books available and Patron's form - a form holding the data of patron's of the library and which book they have and a combo box to enable the librarian to select if the book has been returned or not). My problem is, I want the book database to automatically update when some borrows a particular book to show that that book is unavailable. I hope this makes sense. I just need ideas and suggestions on how I go about doing this I will be forever grateful
VIEWS ON THIS POST

74

Posted on:

Wednesday 28th November 2012
View Replies!

Keydown

...I am having some issues with the Form_Keydown event. It works fine normally, but what can I do if I have to have buttons and textboxes in my form You can't naturally reselect the form, and the Keydown events never take place...any help P.S.
VIEWS ON THIS POST

55

Posted on:

Wednesday 28th November 2012
View Replies!

Identifier

textbox is Name.txt, if for the picturebox is and i also got a problem saying that Clear is not the member of picture box, may i know using what
VIEWS ON THIS POST

57

Posted on:

Wednesday 28th November 2012
View Replies!

Grade an exam

I am to create an application that will grade the written portion of an exam. I am not able to figure out what I am doing wrong. Could someone point in the right direction Here is the code I have so far. Public Class frmExam Public Sub AutoTab(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAnswerOne.TextChanged, txtAnswerTwo.TextChanged, txtAnswerThree.TextChanged, txtAnswerFour.TextChanged, txtAnswerFive.TextChanged, txtAnswerSix.TextChanged, txtAnswerSeven.TextChanged, txtAnswerEight.TextChanged, txtAnswerNine.TextChanged, txtAnswerTen.TextChanged, txtAnswerEleven.TextChanged, txtAnswerTwelve.TextChanged, txtAnswerThirteen.TextChanged, txtAnswerFourteen.TextChanged, txtAnswerFifteen.TextChanged, txtAnswerSixteen.TextChanged, txtAnswerSeventeen.TextChanged, txtAnswerEighteen.TextChanged, txtAnswerNineteen.TextChanged, txtAnswerTwenty.TextChanged 'This will allow the focus to be sent to the next textbox when a character is entered into the answer box Select Case True Case (Len(txtAnswerOne.Text) = 1) txtAnswerTwo.Focus() End Select Select Case True Case (Len(txtAnswerTwo.Text) = 1) txtAnswerThree.Focus() End Select Select Case True Case (Len(txtAnswerThree.Text) = 1) txtAnswerFour.Focus() End Select Select Case True Case (Len(txtAnswerFour.Text) = 1) txtAnswerFive.Focus() End Select Select Case True Case (Len(txtAnswerFive.Text) = 1) txtAnswerSix.Focus() End Select Select Case True Case (Len(txtAnswerSix.Text) = 1) txtAnswerSeven.Focus() End Select Select Case True Case (Len(txtAnswerSeven.Text) = 1) txtAnswerEight.Focus() End Select Select Case True Case (Len(txtAnswerEight.Text) = 1) txtAnswerNine.Focus() End Select Select Case True Case (Len(txtAnswerNine.Text) = 1) txtAnswerTen.Focus() End Select Select Case True Case (Len(txtAnswerTen.Text) = 1) txtAnswerEleven.Focus() End Select Select Case True Case (Len(txtAnswerEleven.Text) = 1) txtAnswerTwelve.Focus() End Select Select Case True Case (Len(txtAnswerTwelve.Text) = 1) txtAnswerThirteen.Focus() End Select Select Case True Case (Len(txtAnswerThirteen.Text) = 1) txtAnswerFourteen.Focus() End Select Select Case True Case (Len(txtAnswerFourteen.Text) = 1) txtAnswerFifteen.Focus() End Select Select Case True Case (Len(txtAnswerFifteen.Text) = 1) txtAnswerSixteen.Focus() End Select Select Case True Case (Len(txtAnswerSixteen.Text) = 1) txtAnswerSeventeen.Focus() End Select Select Case True Case (Len(txtAnswerSeventeen.Text) = 1) txtAnswerEighteen.Focus() End Select Select Case True Case (Len(txtAnswerEighteen.Text) = 1) txtAnswerNineteen.Focus() End Select Select Case True Case (Len(txtAnswerNineteen.Text) = 1) txtAnswerTwenty.Focus() End Select Select Case True Case (Len(txtAnswerTwenty.Text) = 1) btnScore.Focus() End Select End Sub Public Sub AlphaValidation(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAnswerOne.TextChanged, txtAnswerTwo.TextChanged, txtAnswerThree.TextChanged, txtAnswerFour.TextChanged, txtAnswerFive.TextChanged, txtAnswerSix.TextChanged, txtAnswerSeven.TextChanged, txtAnswerEight.TextChanged, txtAnswerNine.TextChanged, txtAnswerTen.TextChanged, txtAnswerEleven.TextChanged, txtAnswerTwelve.TextChanged, txtAnswerThirteen.TextChanged, txtAnswerFourteen.TextChanged, txtAnswerFifteen.TextChanged, txtAnswerSixteen.TextChanged, txtAnswerSeventeen.TextChanged, txtAnswerEighteen.TextChanged, txtAnswerNineteen.TextChanged, txtAnswerTwenty.TextChanged ' this makes sure that you can enter a numeric value into the field 'This will allow the focus to be sent to the next textbox when a character is entered into the answer box Select Case True Case IsNumeric(txtAnswerOne.Text) AndAlso (txtAnswerOne.Text) = " " MessageBox.Show("Your answer cannot be numeric or blank. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerOne.Clear() txtAnswerOne.Focus() End Select Select Case True Case IsNumeric(txtAnswerTwo.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerTwo.Clear() txtAnswerTwo.Focus() End Select Select Case True Case IsNumeric(txtAnswerThree.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerThree.Clear() txtAnswerThree.Focus() End Select Select Case True Case IsNumeric(txtAnswerFour.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerFour.Clear() txtAnswerFour.Focus() End Select Select Case True Case IsNumeric(txtAnswerFive.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerFive.Clear() txtAnswerFive.Focus() End Select Select Case True Case IsNumeric(txtAnswerSix.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerSix.Clear() txtAnswerSix.Focus() End Select Select Case True Case IsNumeric(txtAnswerSeven.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerSeven.Clear() txtAnswerSeven.Focus() End Select Select Case True Case IsNumeric(txtAnswerEight.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerEight.Clear() txtAnswerEight.Focus() End Select Select Case True Case IsNumeric(txtAnswerNine.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerNine.Clear() txtAnswerNine.Focus() End Select Select Case True Case IsNumeric(txtAnswerTen.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerTen.Clear() txtAnswerTen.Focus() End Select Select Case True Case IsNumeric(txtAnswerEleven.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerEleven.Clear() txtAnswerEleven.Focus() End Select Select Case True Case IsNumeric(txtAnswerTwelve.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerTwelve.Clear() txtAnswerTwelve.Focus() End Select Select Case True Case IsNumeric(txtAnswerThirteen.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerThirteen.Clear() txtAnswerThirteen.Focus() End Select Select Case True Case IsNumeric(txtAnswerFourteen.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerFourteen.Clear() txtAnswerFourteen.Focus() End Select Select Case True Case IsNumeric(txtAnswerFifteen.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerFifteen.Clear() txtAnswerFifteen.Focus() End Select Select Case True Case IsNumeric(txtAnswerSixteen.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerSixteen.Clear() txtAnswerSixteen.Focus() End Select Select Case True Case IsNumeric(txtAnswerSeventeen.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerSeventeen.Clear() txtAnswerSeventeen.Focus() End Select Select Case True Case IsNumeric(txtAnswerEighteen.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerEighteen.Clear() txtAnswerEighteen.Focus() End Select Select Case True Case IsNumeric(txtAnswerNineteen.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerNineteen.Clear() txtAnswerNineteen.Focus() End Select Select Case True Case IsNumeric(txtAnswerTwenty.Text) MessageBox.Show("Your answer cannot be numeric. Please enter A,B,C, or D.", "Alpha/Numeric Error", MessageBoxButtons.OK) txtAnswerTwenty.Clear() txtAnswerTwenty.Focus() End Select End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click MessageBox.Show("Thank you taking the exam.", "Thank You", MessageBoxButtons.OK) frmSplash.Close() Me.Close() End Sub Private Sub frmExam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'MessageBox.Show("Please make sure the caps lock is OFF.", "Caps Lock", MessageBoxButtons.OK) 'MessageBox.Show("This form has an auto tab feature. After each question is answered it will automatically move the the next question. When you reach the last question the focus is set to the Score Exam button. Push enter, or click with button with mouse", "AutoTab Feature", MessageBoxButtons.OK) txtAnswerOne.Focus() End Sub Private Sub btnScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScore.Click Dim Key(19) As Char Key(0) = "b" Key(1) = "a" Key(2) = "d" Key(3) = "c" Key(4) = "c" Key(5) = "a" Key(6) = "b" Key(7) = "a" Key(8) = "c" Key(9) = "d" Key(10) = "b" Key(11) = "c" Key(12) = "d" Key(13) = "a" Key(14) = "c" Key(15) = "c" Key(16) = "b" Key(17) = "d" Key(18) = "a" Key(19) = "c" Dim stuAnswer(20) As Integer Dim correct As Integer = 0 Dim incorrect As Integer = 0 Dim totalCorrect As Integer = 0 Dim totalIncorrect As Integer = 0 If Key(0) = stuAnswer(0) Then correct += correct Else incorrect += incorrect End If totalCorrect = correct totalIncorrect = incorrect MessageBox.Show(totalCorrect, (totalIncorrect)) If totalCorrect = 0 Then MessageBox.Show("Wonderful a perfect score. Nice job studing.", "Perfect") End If If totalIncorrect > 7 Then MessageBox.Show("You need to study more", "Study") End If End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click txtAnswerOne.Text = "" txtAnswerTwo.Text = "" txtAnswerThree.Text = "" txtAnswerFour.Text = "" txtAnswerFive.Text = "" txtAnswerSix.Text = "" txtAnswerSeven.Text = "" txtAnswerEight.Text = "" txtAnswerNine.Text = "" txtAnswerTen.Text = "" txtAnswerEleven.Text = "" txtAnswerTwelve.Text = "" txtAnswerThirteen.Text = "" txtAnswerFourteen.Text = "" txtAnswerFifteen.Text = "" txtAnswerSixteen.Text = "" txtAnswerSeventeen.Text = "" txtAnswerEighteen.Text = "" txtAnswerNineteen.Text = "" txtAnswerTwenty.Text = "" txtAnswerOne.Focus() End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click MessageBox.Show("Thank you for taking the exam.", "Thank You") frmSplash.Close() Me.Close() End Sub Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click 'display an about box MessageBox.Show("Drivers License Exam version 1.0", "About") End Sub End Class
VIEWS ON THIS POST

50

Posted on:

Wednesday 28th November 2012
View Replies!

Launching runas.exe from a Visual Basic program

I am trying to make a "Run As" program for my computer (and others) (since Microsoft took it out of their GUI for Vista. I have it set up so that you browse for a file, type in a username, and hit "Run As" (a button). It was suppose to (after you hit "Run As") a Command Prompt will popup asking for a password. Didn't work that well. I am using this code: Shell("cmd.exe /k runas.exe /user:" + TextBox2.Text + " " + TextBox1.Text) What it was supposed to do was put this on the command line cmd.exe /k runas.exe /user:(username) (location of file) it got up to was cmd.exe /k runas.exe How do I get it to process the parameters of runas.exe Thank you all. Great website! This post has been edited by apease11: 22 July 2008 - 04:50 PM
VIEWS ON THIS POST

122

Posted on:

Wednesday 28th November 2012
View Replies!

vb.net and access issues

I am haveing an issue with vb.net. For somereason i can delete and change records in the access database that i have created but i can't see to add a whole new record correctly. It does phyically add the record but it always conflicts with the currencymanager. Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click Dim newDataRow As System.Data.DataRow Dim radioReturn As String If MessageBox.Show("Add record", "Confirm", MessageBoxButtons.YesNo) = DialogResult.Yes Then newDataRow = DsStocks1.tblStocks.NewRow newDataRow.Item("fldStockName") = txtStockName.Text newDataRow.Item("fldTicker") = txtTicker.Text newDataRow.Item("fldShare") = Val(txtShares.Text) newDataRow.Item("fldPurchasePrice") = Val(txtPurPrice.Text) newDataRow.Item("fldPcommission") = Val(txtPurComm.Text) newDataRow.Item("fldSoldPrice") = Val(txtSalePrice.Text) newDataRow.Item("flsSCommission") = Val(txtSaleComm.Text) newDataRow.Item("fldGainLoss") = Val(lblGainLoss.Text) If rdoNewYork.Checked Then radioReturn = "New York" ElseIf rdoAmerican.Checked Then radioReturn = "American" ElseIf rdoNASDAQ.Checked Then radioReturn = "NASDAQ" End If newDataRow.Item("fldExchange") = radioReturn DsStocks1.tblStocks.Rows.Add(newDataRow) daStocks.Update(DsStocks1) End If like i said id does acually write to the database but if i try and look at the next record i get an error An unhandled exception of type 'System.Data.ConstraintException' occurred in system.data.dll Additional information: Column 'fldStockName' is constrained to be unique. Value '10' is already present. the code for the nex record button is Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click If currManager.Position < (currManager.Count - 1) Then currManager.Position += 1 Else MessageBox.Show("No more records.") End If End Sub any help would be awsome thanx
VIEWS ON THIS POST

123

Posted on:

Wednesday 28th November 2012
View Replies!

Linking a selction of text boxes to 1 private sub?

, Pretty new to VB, only started it a few weeks ago so i apologize if this is pretty straight forward. Basically i have 7 text boxes, and i only want numerics to be entered, no letters at all. I have the code sorted, but must i do it for each individual text box or can i use some sort of code so that the other 6 text boxes will copy the 1st one i done Private Sub txtDM_KeyPress(KeyAscii As Integer) 'txtDM is the first of my tesx boxes Select Case KeyAscii Case 48 To 57, 8 ' 0-9 and backspace 'Let these key codes pass through Case Else ' others get trapped KeyAscii = 0 ' set ascii 0 to trap others input End Select End Sub If its any use, txtCM is my second textbox incase someone can show a way to link
VIEWS ON THIS POST

101

Posted on:

Thursday 29th November 2012
View Replies!

Mouse Disable

I am using VB 6 to control the X/Y axis on a laser engraver. I am using for next loops as timers to control the stepper motors speeds. The PC and the laser are seating on the same table. Any vibration caused by the motors some times is detected by the mouse resulting in a rough movement of the motors. If the mouse is moved while the motors are in motion I get the same thing a very rough and erratic motion of the motors. Is there a way I can disable the mouse while the motors are in motion Or is there another way to prevent this. I am considering using a joy stick instead of the mouse but still I would like to know how to enable/disable the mouse under program control.
VIEWS ON THIS POST

64

Posted on:

Thursday 29th November 2012
View Replies!

time monitoring system

hi! I'm an IT student who's having a hard time learning vb yet I still REALLY want to learn the said programming language. Right now, I'm working on a system-a time monitoring system for our upcoming research defense (more like of a thesis). This system will be presented to our chosen company for them to test for a few weeks and will also be graded by the company afterwards. The time monitoring system will be used by the company instead of the usual time cards. Of course, the system will likely to have a database. I kinda learned some simple coding about creating an ADO connection.Here is a simple code I made: Option Explicit Dim myConn As New ADODB.Connection Dim myRS As New ADODB.Recordset Private Sub Form_Load() myConn.Provider = "Microsoft.Jet.OLEDB.4.0" myConn.ConnectionString = _ "Data Source=C:\Documents and Settings\kaye\My Documents\Visual Basic Programs\ADO connection\dbSample.mdb" myConn.Open Set myRS = New ADODB.Recordset myRS.Source = "Select * from tblSample" myRS.ActiveConnection = myConn myRS.CursorType = adOpenDynamic myRS.LockType = adLockOptimistic myRS.Open End Sub Private Sub cmdAdd_Click() With myRS If cmdAdd.Caption = "Add" Then Text1 = "" Text2 = "" Text3 = "" .MoveLast Text1.Enabled = True Text2.Enabled = True Text3.Enabled = True Text1 = .Fields(0) + 1 Text1.SetFocus Text1.SetFocus Else .MoveFirst .Find "authorID = '" & Text1 & "'" If .EOF = True Then If Text2 = "" Or Text1 = "" Or Text3 = "" Then MsgBox "incomplete Record" Exit Sub Else .AddNew .Fields(0) = Text1 .Fields(1) = Text2 .Fields(2) = Text3 .Update .Requery MsgBox "Record Added Successfully" .MoveFirst Text1 = .Fields(0) Text2 = .Fields(1) Text3 = .Fields(2) cmdAdd.Caption = "Add" Text1.Enabled = False Text2.Enabled = False Text3.Enabled = False End If Else MsgBox "Author ID already Exist" End If End If End With End Sub Private Sub cmdDelete_Click() Dim ans As Byte With myRS ans = MsgBox("Are you sure", vbQuestion + vbYesNo) If ans = vbYes Then .Delete .Requery MsgBox "Record deleted..." .MoveFirst Text1 = .Fields(0) Text2 = .Fields(1) Text3 = .Fields(2) End If End With End Sub Private Sub cmdFirst_Click() With myRS .MoveFirst Text1 = .Fields(0) Text2 = .Fields(1) Text3 = .Fields(2) End With End Sub Private Sub cmdLast_Click() With myRS .MoveLast Text1 = .Fields(0) Text2 = .Fields(1) Text3 = .Fields(2) End With End Sub Private Sub cmdNext_Click() With myRS If .EOF = True Then MsgBox "End of File" .MoveLast Text1 = .Fields(0) Text2 = .Fields(1) Text3 = .Fields(2) Else Text1 = .Fields(0) Text2 = .Fields(1) Text3 = .Fields(2) .MoveNext End If End With End Sub Private Sub cmdPrevious_Click() With myRS If .BOF = True Then MsgBox "Beginning of File" .MoveFirst Text1 = .Fields(0) Text2 = .Fields(1) Text3 = .Fields(2) Else Text1 = .Fields(0) Text2 = .Fields(1) Text3 = .Fields(2) .MovePrevious End If End With End Sub Private Sub cmdSave_Click() If cmdSave.Caption = "Save" Then Text2.Enabled = True Text3.Enabled = True Else If Text1 = "" Or Text2 = "" Or Text3 = "" Then MsgBox "There is nothing to edit", vbInformation Else With myRS .Update .Fields(0) = Text1 .Fields(1) = Text2 .Fields(2) = Text3 cmdSave.Caption = "Edit" MsgBox "Edit Succesfull" Text2.Enabled = False Text3.Enabled = False End With End If End If End Sub Private Sub cmdSearch_Click() Dim ID As String ID = InputBox("Enter author ID here: ") With myRS .Find "authorID = '" & ID & "'" If .EOF = True Then MsgBox "Record does not exist!" .MoveFirst Else MsgBox "Record found!" Text1 = .Fields(0) Text2 = .Fields(1) Text3 = .Fields(2) End If End With End Sub What I want to learn is; when I enter the authorID in the TExtbox and I clicked a command button, it will display the author's name. with my time monitoring system: I want to display the time in digital mode but with my code, It didn't work.. The real time was not displayed, instead the number 0 is shown. Dim temptime As Long Dim elapsed As Long Dim H As Long Dim M As Long Dim S As Long Private Sub Command1_Click() temptime = hour(Now) + Minute(Now) + Second(Now) + 30 Label1 = temptime End Sub Private Sub Command2_Click() elapsed = hour(Now) + Minute(Now) + Second(Now) Timer1.Enabled = False Label2 = elapsed Label3 = (temptime - elapsed) & "Seconds" End Sub Private Sub Form_Load() Label4 = H Label5 = M Label6 = S Timer1.Interval = 1000 Timer1.Enabled = False End Sub Is my code right please help me. I really need to pass this course... this site really helps..
VIEWS ON THIS POST

101

Posted on:

Thursday 29th November 2012
View Replies!

i need to have on the form only the up down left and right arrow keys

is there a way i can write in the keypress sub write in what happens if the right and left keys are pressed because i can already do up and down thnx john This post has been edited by orangeslide8: 25 February 2007 - 11:18 AM
VIEWS ON THIS POST

130

Posted on:

Thursday 29th November 2012
View Replies!

How can I send an email to a GROUP in my contact list

Hi Have the code below which is mainly working but, how do you send the e-mail to a "group" in my contact list e..g if the Group is called Work 1 Set oApp = CreateObject("Outlook.Application") Set oMail = oApp.CreateItem(0) With oMail .To = "Work 1" ** .Subject = "File" .Body = "Here is the file you asked for" .Attachments.Add WB.FullName .Display End With
VIEWS ON THIS POST

87

Posted on:

Thursday 29th November 2012
View Replies!

how to arrange order of records using vb code

i am working with a program vb6 - ADODC-access database. while adding new records, the last records saves somewhere between two existing records. so i want to make it in ascending/descending order before print. but confused in writing code. please help
VIEWS ON THIS POST

189

Posted on:

Friday 30th November 2012
View Replies!

LAN with Mysql database

plz help me\tplzi cant connect with my database.the databae is mysql..the client cant read the database when i run the program in the client side.plz help me this is for my project.
VIEWS ON THIS POST

129

Posted on:

Friday 30th November 2012
View Replies!

Programing for MSR 206

I'm new to visual basic, I just got Visual Basic 6.0. I want to make a program to read from an MSR 206 reader. It has a pretty easy to understand programming manual included (http://www.ute.com/f...r206progman.pdf). I need to know how to auto detect which port it's connected to, how to send it commands, and how to read the replies. Also how to run a command when I get a certain reply. This post has been edited by devilsson2010: 25 December 2008 - 05:49 PM
VIEWS ON THIS POST

55

Posted on:

Friday 30th November 2012
View Replies!

copy image to webserver using vb6.0

Hi.. we have desktop application developed in vb6.0 which upload a image file and afterward it shown in web application. i want a code to upload a image file to web service.
VIEWS ON THIS POST

128

Posted on:

Friday 30th November 2012
View Replies!

check if control has a property

I have found some code on the internet which disables all the controls in a frame. I use this code in the load event of a form, disabling all the controls in 2 frames but at a certain point in the code I want to re-enable some of them depending on a text file. I want to re-enable them by comparing strings between the text file and the caption of the option buttons or check boxes but the problem I am having is that not all of the controls in the frame have a caption property (textboxes are the main culprit) and therefore an error is thrown up stating that the object doesn't support the property. My question is this: is there a way to check whether a control has a certain property, in my case the Caption property would be useful to check. Here is the code that re-enables the controls, the error appears on the "if" line and the "Extras()" variable is retrieved from a text file: For Each ctrl In Me.Controls For i2 = LBound(Extras) To UBound(Extras) If ctrl.Container Is frmPaintExtras And ctrl.Caption = Extras(i2) & " Finish" Or ctrl.Container Is frmExtras And ctrl.Caption = Extras(i2) Then ctrl.Enabled = True i2 = UBound(Extras) End If Next i2 Next This post has been edited by rainbow evil: 31 January 2010 - 03:34 PM
VIEWS ON THIS POST

66

Posted on:

Friday 30th November 2012
View Replies!

Index out of bouns

hi experts, I'm having a problem in my listview i need my listview items to be inserted in a table but error pops when i run it here is my code for the inserting items that has error For i = 0 To LstS.ListItems.Count - 1 strSQL = "INSERT INTO ItemBorrowed " & "(ID,ItemName,ItemDescription,Quantity) " & " VALUES (" & _ "'" & cboID & "'," & "'" & LstS.ListItems.Item(i) & "'," & "'" & LstS.ListItems.Item(i).SubItems(1) & "'" & "'" & LstS.ListItems.Item(i).SubItems(2) & "')" dbCmd.CommandText = strSQL dbCmd.Execute Next Unload Me End Sub the error is in the strSQL statement i don't know what is the problem with it can you tell me\t This post has been edited by ravmonster: 18 October 2009 - 06:19 AM
VIEWS ON THIS POST

75

Posted on:

Friday 30th November 2012
View Replies!

DATA TYPE MISMATCH?

i have this code that gets the First and Last Name of a person with an ID that is selected on a ComboBox but it give's error can you help me find out what is wrong with it..... the ERROR is DATA TYPE MISMATCH..... here is the code Private Sub cboID_Click() Dim strSQL As String Dim REC As New Record strSQL = "SELECT FirstName,LastName FROM Borrower WHERE ID = " & cboID dbCmd.CommandText = strSQL Set REC = dbCmd.Execute With REC Do Until .EOF First.Text = !FirstName Last.Text = !LastName .MoveNext Loop End With REC.Close End Sub the dataformat for the cboID is set to Number and the Datatype of the Field ID is Number. Can you Tell me what is wrong with it\t\t PLISSSSSSSSSSSS This post has been edited by ravmonster: 16 October 2009 - 09:09 AM
VIEWS ON THIS POST

62

Posted on:

Friday 30th November 2012
View Replies!

Cartesian Plane VB6

I just want to know how to setup a Cartesian plane and make simple graphs (such as a line or parabola) in vb6. I was searching the web and found some help on mschart but its really complicated. If someone could help me get started I would appreciate it. Thank You.
VIEWS ON THIS POST

70

Posted on:

Friday 30th November 2012
View Replies!

Need Help w/ Input Files Please

I needs some help with some homework from my Visual Basic Class. The question reads: Write a program to analyze the list and report the two highest variables. We are given a external Document that contains a name then variable then name and variable and so on. Here is my code so far but im so lost can anyone help me Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Total As Double Dim num As Double Dim Largest As Double Dim SecondLargest As Double Dim sr As IO.StreamReader = IO.File.OpenText("BIDS.TXT") Total = 0 Do While sr.Peek -1 Name = (sr.ReadLine) num = (sr.ReadLine) If num > Largest Then Largest = num If Largest > num Then SecondLargest = num End If End If Loop txtOutput.Text = "Largest Number = " & Largest & " Second Largest = " & SecondLargest End Sub End Class EDIT : Added Code Tags -b2c
VIEWS ON THIS POST

59

Posted on:

Friday 30th November 2012
View Replies!

Datagrid Problem

Dear all, I have a problem in datagrid i am using this peace of code to fetch all data from database in datagrid but it gives me error object required please help me Set db = OpenDatabase("D:\EA\DB\EA.mdb") Set rs = db.OpenRecordset("Admission") admissionsql = "SELECT StudentID,StudentName" _ & " FROM admission " _ & "Order by StudentID" Set DataGrid1.DataSource = admissionssql This post has been edited by naveed_786: 12 December 2010 - 04:12 AM
VIEWS ON THIS POST

79

Posted on:

Monday 3rd December 2012
View Replies!

Undocumented Communication DLL

Need to rewrite a system that communicates with a RFID Card Reader/Writer. I have determined that the communication interface DLL file (attached hereto) was written in Delphi but NO documentation is available to determine the functions and parameters to pass to the Com-Port and what to expect back. I understand the Opening / Closing & OnComm event that I need to put in my program. Is there any way that anybody can help me with this "Non-touch IC Card Communication Interface of XT-6"\t!!
VIEWS ON THIS POST

61

Posted on:

Sunday 23rd December 2012
View Replies!