How do you celebrate your birthday?
I do not
I got 27
You are an average on-line user. You may surf the Web a bit too long at times, but you have control over your usage.
hi MichelleCrews,
welcom to Daniweb ! I hope you will enjoy here and learn more to get A :D
Apr 17th, 2006 > this thread brings memory when I was doing my project :(
however, it is better to open new thread with title that describe your problem
plz...m relly need a immediate coding..
plz sumbody solve my probs..
i want to subtract my current quantity stock went m enter any amount at a textbox...
currentquantity = fullquantity - amount(type in the textbox)
then save to database
can sumbody help mee..plzzz
As Teme64 said open new thread with appropriate title and you will get more help
However,
currentquantity = fullquantity - amount(type in the textbox)
Dim currentquantity, fullquantity As Double
currentquantity = fullquantity - CDbl(TextBox1.Text)
this is what I understand from your question
and see this link to know how to add row to Database
Is it necessary to write only under MouseUp? Why not under Cell Click / CellContent Click?
o, not necessary but I thought it will work
Because I remember that when I once used click event it was fired only when I click the header of datagrid not the cell content :S , you can try (or search on net) for what each event do
Private Sub add(Of T)(ByVal x As T, ByVal y As T) Dim res As T res = x + y MsgBox(res) End Sub
what type T ??
do you get error, or the program run but no change made to database or what ?
When i click on the ID field that id should get displayed in the ID TEXT FIELD...
do you mean display it on TextBox? if yes then use MouseUp event handler inorder to know when user select the cell, and then display the cell content in textbox
Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseUp
TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, NumOfIDColumn)
End Sub
DataGrid1.CurrentCell.RowNumber will return current cell that user select
NumOfIDColumn refers to the ID column in your dataset if it's the first column then you will write
DataGrid1.Item(DataGrid1.CurrentCell.RowNumber,0)
Note that even when user clicked the Name column in first row , the program will still display the ID in textbox
see this link
I hope that will help you
timothybard is right, just Cdbl won't solve it :)
it would be better if you post your code
any way , I think you didn't convert from string to double before calculating,
you wrote like this
Balance.Text = coursefees - installment1.Text
it may work but if user did not enter value and leave the textbox empty then you will have cannot convert string "" to double error
to solve it
Balance.Text = coursefees - CDbl(installment1.Text)
I hope this will help you
i have to input number in all textboxes so it gives me a zero in the total. also i have an error coming up its text is not member of double. please help on this.
sorry but I don't understand the problem , you mean the total is always zero?
other thing,in your code what the names of the input textboxes , for example is it RoomService or dblRoomService ?
Note:
It is better if use the CODE tag so your post will be easier to read
thank you all especailly to ZachMack who remind me of my first post here :D
and welcome to DaniWeb.
1/to use image in the form you need PictureBox Control
2/in order to change the picture whenever the user select item from the comboBox you use the SelectedIndexChanged event, you can get the item that user selected by
dim selectedItem as string
selectedItem = ComboBox.Text
I just wanna discuss about that difficulty, have some advises and know about difficult that you find or found out to plan yours careers.
About me I had job interview few days ago , he asked me what your career plan for the next 5 years :S
I really did not have any :( I started to read about how to plan the career but shouldn't I have job first then think of this ?
:) to learn how to program you need to try at first then learn from your mistakes
however, yes that code should read the line 5 to textbox
to read from file line by line you need to use ReadLine method as you did , plus checking if you reached the end of file or not by Peek method
While loadf.Peek <> -1
Line = loadf.ReadLine()
...
...
End While
Please just give me the code to read line 5 for example, then i will do the rest,
i am not sure if I understand you, you want to write line 5 in the textbox? then in the while loop above check if you reached line 5 by counter then if yes show the line in textbox
n = 0
While loadf.Peek <> -1
n = n + 1
Line = loadf.ReadLine()
If n = 5 Then
TextBox1.Text = Line
End If
End While
Public Sub save(ByVal sav As Double) If sav= 0.0 Then Console.WriteLine("Is not valid") Else mainsave = sav End If
what I understand that the user will enter the value in textbox , after you check that user did not leave it empty you can use it .
Dim save As Double
If TextBox1.Text = "" Then ' check if the textbox is empty
save = 0.0
MessageBox.Show("Empty Double")
Else
save = Convert.ToDouble(TextBox1.Text) 'if it is not empty convert the string to double and store it in save variable
End If
also you can validate the user's input before you store it in save variable.
I hope that help you
i need sample project using vb.net if u know anything please send me
it is better you open new thread, and i suggest to search here since many ask same thing , Good Luck
Dim varConnection As New SqlConnection
Dim varDataSet As New DataSet
Dim varAdapter As SqlDataAdapter
Dim varCommand As SqlCommand
Dim varchar As SqlDataAdapter
Dim sql As String
Dim Number_of_Rows As Integer
varConnection = New SqlConnection("Server=(local);user id=sa;password=;Initial Catalog=ROP1")
sql = "SELECT * FROM tbl_rop"
varCommand = New SqlCommand(sql, varConnection)
varAdapter = New SqlDataAdapter(varCommand)
varAdapter.Fill(varDataSet)
if you removed these lines, return them and see if you still have this problem
:S
Additional information: Cannot find table 0.
TextBox1.Text = varDataSet.Tables(0).Rows(1).Item("Name_User")
there is no table 0 in your dataset
dim Record_num as integer=0
.
.
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.ClickNumber_of_Rows = Me.DataSet11.Tables(0).Rows.Count
If Record_num <> Number_of_Rows - 1 Then
Record_num = +1
TextBox1.Text = varDataSet.Tables(0).Rows(Record_num).Item("Name_User")
TextBox2.Text = varDataSet.Tables(0).Rows(Record_num).Item("Date_of_birth")
TextBox3.Text = varDataSet.Tables(0).Rows(Record_num).Item("Hobbies")
TextBox4.Text = varDataSet.Tables(0).Rows(Record_num).Item("Phone_number")
end if
sorry I was mistaken here, Record_num should be initialized with -1 not 0
this time it should really work , just be sure of your dataset that it contains table 0 :S
the error
"update requires a valid insertCommand when passed DataRW collection with new rows"
tells you that when you add new row using
Dap.Update(DsS, Table)
, you must set insertCommand's properties
The update is performed on a by-row basis. For every inserted, modified, and deleted row, the Update method determines the type of change that has been performed on it (Insert, Update or Delete). Depending on the type of change, the Insert, Update, or Delete command template executes to propagate the modified row to the data source. When an application calls the Update method, the DataAdapter examines the RowState property, and executes the required INSERT, UPDATE, or DELETE statements iteratively for each row, based on the order of the indexes configured in the DataSet
the source
also see this link
so change the Rowstate to Unchanged by
writing
DsS.Tables(Table).Rows.Add(DrS)
the DrS.AcceptChanges()
I hope that will help you
here are some changes i made to the code.. as always the problem still the same nothing happen... can you figured it out what seems to be the problem....i really appreciate the help
the problem still the same , you mean it just shows the last record ?
if yes , as I said before initializing Record_num with zero inside the button code is your problem
just imagine what will happen if user press Next button for first time
Record_num = 0 and Number_of_Rows =8
the IF statement will compare two numbers and they not equal and it will enter if statement so ,
Record_num = 1
TextBox1.Text = varDataSet.Tables(0).Rows(1).Item("Name_User")
now what will happen if user press Next for second time ?
actually, the same thing
Record_num = 0 and then Record_num =1
while Record_num should equal to 2
so it will show the same row again
I hope I could explain well this time :S
Dim Record_num = 0'i cannot remove the declaration for record num
why you can not remove it ?
declear it in Form1 class not in button code
what are the errors ?
is it solved ? or you still have problem :S
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Dim varConnection As New SqlConnection
Dim varDataSet As New DataSet
Dim varAdapter As SqlDataAdapter
Dim varCommand As SqlCommand
Dim varchar As SqlDataAdapter
Dim sql As String
Dim Record_num = 0 ' you do not need this here
Dim Number_of_Rows As Integer = 0 'why zero? this will hold number of rows in your table so you will be sure that once you reached last record you will not increment it
varConnection = New SqlConnection("Server=(local);user id=sa;password=;Initial Catalog=ROP1")
sql = "SELECT * FROM tbl_rop"sql = "SELECT distinct * FROM tbl_rop"
varCommand = New SqlCommand(varQuery, varConnection)
varCommand = New SqlCommand(sql, varConnection)
varAdapter = New SqlDataAdapter(varCommand)varAdapter.Fill(varDataSet) 'used to get the count of number of rows in a table
Number_of_Rows=varDataSet .Tables("your_table_name").Rows.Count
If Record_num <> Number_of_Rows - 1 Then
Record_num = +1
TextBox1.Text = varDataSet.Tables(0).Rows(Record_num).Item("Name_User")
TextBox2.Text = varDataSet.Tables(0).Rows(Record_num).Item("Date_of_birth")
TextBox3.Text = varDataSet.Tables(0).Rows(Record_num).Item("Hobbies")
TextBox4.Text = varDataSet.Tables(0).Rows(Record_num).Item("Phone_number")
End If
the problem that you decleared Record_num inside the next_button code, here each time the user choose next button Record_num will have the same value
define it outside it
public class form1
dim Record_num as integer=0
other thing , you must check if that Record_num is not last record
If Record_num <> Number_of_Rows - 1 Then
Record_num = +1
TextBox1.Text = varDataSet.Tables(0).Rows(Record_num).Item("Name_User")
TextBox2.Text = varDataSet.Tables(0).Rows(Record_num).Item("Date_of_birth")
TextBox3.Text = varDataSet.Tables(0).Rows(Record_num).Item("Hobbies")
TextBox4.Text = varDataSet.Tables(0).Rows(Record_num).Item("Phone_number")
i do not understand your code.
>>"this the code for button next n previous" you mean that the same code for next and previous ? each one has its own code
i = 0
[B]For i = 0 To -1[/B]
TextBox1.Text = varDataSet.Tables("tbl_rop").Rows([B]0[/B]).Item("Name_User")
TextBox2.Text = varDataSet.Tables("tbl_rop").Rows(0).Item("Date_of_birth")
TextBox3.Text = varDataSet.Tables("tbl_rop").Rows(0).Item("Hobbies")
TextBox4.Text = varDataSet.Tables("tbl_rop").Rows(0).Item("Phone_number")
Next i
TextBox1.Text = varDataSet.Tables("tbl_rop").Rows(0).Item("Name_user")
TextBox2.Text = varDataSet.Tables("tbl_rop").Rows(0).Item("Date_of_birth")
TextBox3.Text = varDataSet.Tables("tbl_rop").Rows(0).Item("Hobbies")
TextBox4.Text = varDataSet.Tables("tbl_rop").Rows(0).Item("Phone_number")
first why you are using for loop ? and why it is for 0 to -1 ? maybe you mean
for 0 to some_variable-1
any way i do not think you need for loop inside next or previous button
other thing in the code you always display the content of row 0
TextBox2.Text = varDataSet.Tables("tbl_rop").Rows([B]0[/B]).Item("Date_of_birth")
the problem is when i want to move to the next data nothing appear...the same when i want to look for previous data...
i think your code should display the contents of the first row.
any way , the idea is just to keep track for the records
declear global variable for that call it for example Record_num=0
then in next button incremnt it by one and in the previouse button decrease it by one
after that display the record
TextBox1.Text = varDataSet.Tables("tbl_rop").Rows(Record_num).Item("Name_user")
.....
you will need dataAdapter and dataset
by using dataset you can update the value of any cell in database
Me.DataSet11.Tables("Table_Name").Rows(0).Item(1) = TextBox1.Text
this will not update your databse , to change it you must write
Me.OleDbDataAdapter1.Update(Me.DataSet11)
inserting new row is like updating, you first add new row into dataset then update dataAdapter
Dim Row As DataRow
Row = Me.DataSet11.Tables("Table_Name").NewRow()
Row.Item(0) = textbox1.text
.....
Me.DataSet11.Tables("table_name").Rows.Add(Row)
Me.OleDbDataAdapter1.Update(DataSet11,table_name)
first thing you need to store the special characters in array , so you will declear array
Dim SC(36) As char
after that store values
SC(0) = "Ï"
SC(1) = "Î"
.......
2-go through the user's string using For loop and for each character in user's string ,which you can get by
x = textbox1.text.Substring(i, 1)
,convert it to the corresponding symbol usingSelect Case
I hope that help you ,try it and if you have questions just ask
If myGuess = randNum Then
here you compare between integer and class Random
to solve this
If myGuess = randNumGenerated Then
same thing in the "<" and ">"
but you need to define randNumGenerated as global variable I think..
any way your game is hard :S at least put max and min number when you generate the random number
I am getting an error called 'Data type mismatch in criteria expression'. This only happen when I tried to add an item.
I think the error means that you have variable from one type and you are trying to store in it value from other type .
since you have this error when you add item then I think your sql statement not right. for example , check that numbers can not have ' around it.
any way post your code please so I may help you more :)
Dim InitialValue As New TextBox
Me.Controls.Add(InitialValue)
Dim SalvageValue As New TextBox
Me.Controls.Add(SalvageValue)
Dim AssetValue As New TextBox
Me.Controls.Add(AssetValue)Dim ppdDepreciation As PrintDialog
msngInitialValue = ToSingle(txtInitialValue.Text)
msngSalvageValue = ToSingle(txtSalvageValue.Text)
mintAssetLife = ToInt32(txtAssetLife.Text)
Variables that you declared are different from what you used .
write your code here please
How can I declare the InitialValue.text, txtSalvageValue.Text and TxtAssetLife.Text part of this code?
You do not declare InitialValue.text you just declare variable as textbox.
textbox has many properties one of them is text
we access properties of InitialValue variable by typing InitialValue. what comes after its property
to declear textbox
Dim InitialValue as New TextBox
Me.Controls.Add(InitialValue)
see this link to understand textbox more
p.s. i assumed your variables of type textbox
x = TextBox1.Text.ToCharArray
While continue = True And (i < x.Length)
If IsNumeric(x(i)) Then
y += x(i)
Else
continue = False
MessageBox.Show("Sorry, only numbers allowed")
End If
i = i + 1
End While
TextBox1.Text = y
any way I think not allowing user from start to violate the rules as Jx_Man suggested is better
What do I need to do to correct that?
you need to do as Jx_Man suggest , use Convert.ToSingle
For i = 0 To fLen1 - 1
snglRead1(i) = br1.ReadSingle() 'EXCEPTION thrown right here
Next
maybe you trying to read while you reached the end of file ,
fLen1 = f1.Length
i think this return length on byte , try this
fLen1 = Int(f1.Length / 4)
I get "value of type 'Integer' cannot be converted tp '1 dimensional array of Char" with the following line of code when attempting to define the columns as suggested: -
arrstrFunctionalArea = New String(n)
error means you defined something as integer then you tried to store in it array of char
I tried the code and I did not have this error
maybe you defined n like this
Dim n As String() ?
My question is, can I convert a column so that it has a checkbox instead of the "True" or "False". i.e. Columns(3) for example
yes you can
after you establish the connection with database , and fill the dataset with data, assuming you have datagrid with name dgdFunctionArea
creat new table and define the columns
Dim dtCol As DataColumn = Nothing 'Data Column variable
Dim arrstrFunctionalArea As String() = Nothing 'string array variable
Dim dtblFunctionalArea As New DataTable 'Data Table var
Dim n As Integer
n = 5 ' n is the number of columns in your table that are not checkbox
arrstrFunctionalArea = New String(n)
arrstrFunctionalArea(0) = "AAC Code"
arrstrFunctionalArea(1) = "Cttr Name"
........
'Create the Data Table object which will then be used to hold columns and rows
dtblFunctionalArea = New DataTable("TableName")
'Add the string array of columns to the DataColumn object
Dim i As Integer
For i = 0 To 4
Dim str As String = arrstrFunctionalArea(i)
dtCol = New DataColumn(str)
dtCol.DataType = System.Type.GetType("System.String")
dtCol.DefaultValue = ""
dtblFunctionalArea.Columns.Add(dtCol)
Next i
now you created columns in table that are not check box as in the artical
after that you creat columns that will hold true/false values
'Add a Column with checkbox in the Grid
'create the data column object with the name TFColumn
Dim dtcCheck As New DataColumn("TFColumn")
'Set its data Type
dtcCheck.DataType = System.Type.GetType("System.Boolean")
dtcCheck.DefaultValue = False 'Set the default value
dtblFunctionalArea.Columns.Add(dtcCheck) 'Add the above column to the Data Table
after that …
to know which row is selected use this
DataGrid1.CurrentRowIndex
to show the value of first column in text box
Me.TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentRowIndex, [B]0[/B])
YourString.Substring(0, YourString.IndexOf("have"))
but you must handle what if "have" does not exist , i think it will give you error
Dim intListIndex As Integer
what i understand from your code that intListIndex is integer , so you can not write
intListIndex.SelectedIndex
to print only what the user select try this
e.Graphics.DrawString(lstProducts.SelectedItem, fntPrintFont, Brushes.Black, sngX, sngY)
i am not sure if i understand you .
any way to check mandatory fields , check they not empty
for example if user must enter ID in textbox check it like this
if Id_textbox="" then
Label1.Text = "you must enter the ID"
end if
about confirming exit the form use msgbox like this
Dim c As Integer
c = MsgBox("are you sure you want to exit", MsgBoxStyle.OKCancel, "Exit")
If c = 1 Then
Me.Close()
End If
i did not understand why u use For loop ,
do you want to show all the array's content in one label ? if yes then
For subscript As Integer = 0 To [B]3[/B]
ratesLabel.Text =[B]ratesLabel.Text[/B]+ " "+ rates(index).ToString
Next subscript
if you want to show only one rate then you do not need for loop , just search in rate array for value correspond to what user entered and then show it in label
hope this help you