P.manidas 39 Posting Whiz in Training

498

P.manidas 39 Posting Whiz in Training

Find the Numbers.......

A teacher says: I'm thinking of two natural numbers greater than 1. Try to guess what they are.
The first student knows their product and the other one knows their sum.
First: I do not know the sum.
Second: I knew that. The sum is less than 14.
First: I knew that. However, now I know the numbers.
Second: And so do I.
What were the numbers?

P.manidas 39 Posting Whiz in Training

The above puzzle is very tough to solved. But any way, The solution is ..

Here,
1 -> 11 (One 1)
11 -> 21 (two 1)
21 -> 1211 (one 2 and one 1)
1211 ->111221 (one 1, one 2 and two 1)
111221 ->312211 (three 1, two 2 and one 1)

Suppose there there is a no. 5861155
for fist digit (5) that is ONE 5 =15
for second digit (8) that is ONE 8=18
for third digit (6) that is ONE 6=16
for forth and fifth digit (11 (though both the digit is same)) those are TWO 1=21
for sixth and seventh digit (55 (though both the digit is same)) those are TWO 5=25

So, the number is 1518162125

Arbus commented: Right answer! +0
P.manidas 39 Posting Whiz in Training

Try this 4 lines of code instead of line nos. of your codes 7 to 11

txtINameS.Text = Myrs("ItemNameSize").Value
If Myrs.RecordCount = 0 then
MsgBox "No Record Foun.Try again"
Endif
P.manidas 39 Posting Whiz in Training
P.manidas 39 Posting Whiz in Training
P.manidas 39 Posting Whiz in Training

Dear Debasisdas,

Sir, it has worked nicely. Its great. Thank you sir. I have tested on another two machine (i.e with 3 nos. machine)

P.manidas 39 Posting Whiz in Training

The number is 2519

Arbus commented: Perfect! +0
P.manidas 39 Posting Whiz in Training

Can somebody delete this thread? Because, I have open a same thread on Visual_Basic_4/5/6 after not getting any reply here. May be i have posted wrongly here. Please delete this thread.

Same thread is http://www.daniweb.com/software-development/visual-basic-4-5-6/threads/362499

P.manidas 39 Posting Whiz in Training

Being positive or negative are habits of thoughts that have a very strong influence on life.

P.manidas 39 Posting Whiz in Training

Dear Debasisdas,

Ok sir, that thing i understand. Actually i thought there is an option in the process of making Setup file. Any way, I will write here soon after testing. Thank you sir.

P.manidas 39 Posting Whiz in Training

Dear Debasisdas,

Ok sir, I will write to you after testing the whole process. But the 2nd no. is little bit confusing me.

P.manidas 39 Posting Whiz in Training

See this example. And try with your codes.

ST = "select * from table1 where empno="
ST = ST + "'" + TxtEmpNo.Text + "'"
cmd = New OleDbCommand(ST, cn) ' where empno=" + "'" + TxtEmpNo.Text + "'", cn)
dr = cmd.ExecuteReader()

dr.Read()
If dr.HasRows Then
   TextBox1.Text = dr("empno")
   TextBox2.Text = dr("Ename")
   TextBox3.Text = dr("Department")
End If
dr.Close()
P.manidas 39 Posting Whiz in Training

Ok lielee, tables food items are fixed. Whenever they want to add new food item they must have to call you. You have added field as food item into table in design mode or at the run time, whatever it may be.

And you are trying to add the price of food into the respective column (food item) at the first row of the table. And you are getting problem whenever you tried to add the second item's price of food (that is taking as new row)

If it is the case, then you can add the price of food as .....

1. First in the design mode(or at the run time, whatever you used) put zero into the 1st row of the table (in every cell in respective column i.e your food item).

2. Next you edit(update) the data(i.e. zero) giving condition to your Column (food item)

I think by this way you can solve your problem.

P.manidas 39 Posting Whiz in Training

Dear Debasisdas,

I have tested half(i.e changed the network path(another machine path) and placed the database into that path and accessing from my machine(without making setup file because in my machine VB 6.0 is installed)) of that and its working.

If i will installed the programe by setup file into no. 3rd machine. Will it worked? Because, i have not tested yet.

If the above query's answer is YES
and
If i will place the database into one machine keeping the path of database of that machine. Suppose i want to run the programe from no. 2, 3 or 4 machines. Is it necessary to installed the programe in every (no. 2, 3, 4) machines? or Is there another ways?

Please guide me sir.

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

I have a small programe developed in VB 6.0 and database MS Access. Where user can insert their only name & address and can retrieve the existing records.

Just for test, I have kept this programe (.exe file and database file) in the share document of a computer and tried to run from another computer. It was running smoothly (I entered records and display that records too). I have not made setup file when i was tested. Just created .exe file.

I want to run this programe in home network that is connected with router. How can i run this programe after installing (I know how to make setup file in VB 6.0) into a computer? Please guide me.

#### There is no server in our Home Network. All computers OS is Windows XP Profesional S2

P.manidas 39 Posting Whiz in Training

“We are what our thoughts have made us; so take care about what you think. Words are secondary. Thoughts live; they travel far.”

- Swami Vivekananda -

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

I have a small programe created in VB 6.0 and database MS Access. Where user can insert their only name & address and can retrieve the existing records.

Just for test, I have kept this programe (.exe file and database file) in the share document of a computer and tried to run from another computer. It was running smoothly (I entered records and display that records too). I have not made setup file when i was tested. Just created .exe file.

I want to run this programe in home network that is connected with router. How can i run this programe after installing (I know how to make setup file in VB 6.0) into a computer? Please guide me.

#### There is no server in our Home Network. All computers OS is Windows XP Profesional S2

P.manidas 39 Posting Whiz in Training

Lielee, What i understand from your two post in this thread that you have design your database as like this

TiramisuCake--RedVelvetCake--VanillaFrenchCake----> these are column name (food name)
----------50----------------100-------------20----------------> price of food

You need to enter the price of food under the food column name as shown above

If it is the case then i have questions for you.

1. If you need to enter the new food item what you will do?
2. From where you have loaded the food item into combobox?


My suggession is to design your database like this. See, if it is suitable for you


NameofFood-----------PirceOfFood
TiramisuCake-------------50
RedVelvetCake------------100
VanillaFrenchCake--------20

Here you can insert new food items whenever you needed. You can insert food item and price of food. or if you insert the food item first and later on price of food then you have to edit that perticular row's filed i.e price of food.

Hope i understand your database. if not sorry.

P.manidas 39 Posting Whiz in Training

Try this one

Dim Complete As Boolean = False
Dim Com As Boolean= False
Dim PlaceNum As String
Dim i As Integer
Dim j As Integer

Dim Num1 As Integer=1
Dim Num2 As Integer=1


Do While Complete = False
If listbox1.Items.Count > 1 Then
For j = 0 To listbox1.Items.Count - 2 Step 1
    PlaceNum = listbox1.Items(j)
    For i = j + 1 To listbox1.Items.Count - 1 Step 1
        If PlaceNum = listbox1.Items (i) Then
            Num1 = Num1 * Val(listbox1.Items (i))
            listbox1.items.RemoveAt (i)
            listbox1.items.RemoveAt (j)
            Complete = False
            Com = True
            Exit For
        Else
            Com = False
        End If
     Next i
     
     If listbox1.Items.Count = 1 Then
     Complete = True
     Exit For
     End If
     
     If Com = True Then
        Exit For
     End If
     
     If j = listbox1.Items.Count - 2 Then
        Complete = True
     End If
Next j
Else
Complete = True
End If
Loop

For i = 0 To listbox1.Items.Count - 1 Step 1
Num2 = Num2 * listbox1.Items (i)
Next i

Textbox1.Text = Num1
Textbox2.Text = Num2
tstory28 commented: The code was right on the nose. He figured out exactly what I needed. +1
P.manidas 39 Posting Whiz in Training

I read the story, that building slowly...

P.manidas 39 Posting Whiz in Training

Who was the story writer, you know?

P.manidas 39 Posting Whiz in Training

Do you know what was the date?

P.manidas 39 Posting Whiz in Training

By this below codes you can check how many words are there on single line or multi line text box even if user enter space in between and before or after words.

Private Sub Command1_Click()
Dim Counts As Integer
Dim dupText As String

dupText = Replace(Trim(Text1.Text), vbNewLine, " ")

If dupText = "" Then
    Counts = 0
Else
    Counts = 1
    For i = 1 To Len(dupText)
        If Mid(dupText, i, 1) = " " Then ' use Mid to search space
            If Mid(dupText, i - 1, 1) <> " " Then
                Counts = Counts + 1
            End If
        End If
    Next
End If
MsgBox Counts
End Sub
debasisdas commented: agree +12
dnk commented: Thanks for duplicate checking :) +2
WaltP commented: and thanks for doing his homework for him. Now he doesn't have to think. -3
P.manidas 39 Posting Whiz in Training

Dear Debasisdas,

Thank you sir.

P.manidas 39 Posting Whiz in Training

Dear Debasisdas,

MCA from Sikkim Manipal University through correspondence course will it be better or from other university? Though, i am working in a company i have to go for correspondence course.

I am 32+ of age. Will age factor prevent me somewhere?

P.manidas 39 Posting Whiz in Training

Dear Debasisdas,

Thanks for your suggestions. Yes, i am going to have as you advice. Thanks a lot sir.

P.manidas 39 Posting Whiz in Training

Dear Twigan1015,

I am sorry but confused what you are asking here. What i understand is...

You have four column/Field UPC, Quantity, Price and Total. You want to add all these four column's data into a listbox as listitem. And after that you will save it into a text file. And whenever it needed the data of text files, you will retrieve into a listbox.

For calculating purpose which field/column' data you will provide as input data? As i understand you will provide only UPC and Quantity. What about price of quantity?

Let us know it clearly.

P.manidas 39 Posting Whiz in Training

Dear Kishjeff,

Thanks for replying, i am always ready to travel but degree is preventing me. Thank you.


Dear Debasisdas,

Thanks for replying sir. Yesterday, i tried to reply but due to power problem i could not reply sir. Anyway, whatever you have written all are true for me. I have to admit that.

As you mentioned regarding "latest version of .net + SQL Server". Is that VB 2010 or other language of .net version and My SQL Server or MS SQL Server or both of them?

And regarding technical education, will MCA be sufficient?

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

I am a B.A. graduate from Guwahati University of Assam, India and having one year Diploma course in Computer Application. I have assist in developing a Library Management System which is running smoothly in various colleges in Assam, India. And have developed some non-commercial software for personal excellence such as Chain System Networking Growth Business Software, PG Quiz Master, Puzzle Cells, Puzzle Numbers etc. All these software was developed using VB 6.0 and MS Access.

I want to be a software programmer in software companies. I know C and C++ too but I can’t say that I am good in these two languages and these days I am learning VB 2008 also.

I know I have to increase my knowledge in some areas to become a good software programmer. But what should I learn? Is it necessary to have a computer degree? Which language and database(I know My SQL little) will be good for me for better career?

Please guide me Sir/Madam, because becoming a software programmer is my strong desire.

Thanks

P.manidas 39 Posting Whiz in Training

It's good to share your codes too. Happy coding.....

P.manidas 39 Posting Whiz in Training

See my reply to this thread. It may help you. Just follow the link below...

http://www.daniweb.com/software-development/vbnet/threads/360042/1538176#post1538176

P.manidas 39 Posting Whiz in Training

Adding 7 nos. textbox's text into a listbox

lstAlbums.Items.Add(Form1.textbox1.text.ToString)
lstAlbums.Items.Add(Form1.textbox2.text.ToString)
lstAlbums.Items.Add(Form1.textbox3.text.ToString)
lstAlbums.Items.Add(Form1.textbox4.text.ToString)
lstAlbums.Items.Add(Form1.textbox5.text.ToString)
lstAlbums.Items.Add(Form1.textbox6.text.ToString)
lstAlbums.Items.Add(Form1.textbox7.text.ToString)

For saving a listbox item into a text file

'for saveing listitem into text file
Dim Objfile As New System.IO.StreamWriter("C:\TestText.txt")
Dim intCounter As Long 
For intCounter = 0 To lstAlbums.Items.Count - 1
    objFile.WriteLine(lstAlbums.Items(intCounter).ToString)
Next intCounter

Objfile.Close()
Objfile.Dispose()

Retrieving textfile(i.e list items saved in the text file) into listbox on form load event

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Reading and adding into a listbox
Try
   Dim objFile As New System.IO.StreamReader("c:\TestText.txt")
   Dim strAlbumName As String
   strAlbumName = objFile.ReadLine()
   Do Until strAlbumName Is Nothing
        LstAlbums.Items.Add(strAlbumName)
        strAlbumName = objFile.ReadLine()
   Loop
   objFile.Close()
   objFile.Dispose()
   Catch ex As Exception
      MsgBox("The file could not be found.")
   End Try
End Sub

in my codes Listbox name is lstAlbums

P.manidas 39 Posting Whiz in Training

If you want to add list item of listbox1 of from1 to listbox1 of Form2

write the below codes in form2_load event....

Dim a As Integer
ListBox1.Items.Clear()
For a = 0 To Form1.ListBox1.Items.Count - 1 Step 1
    ListBox1.Items.Add(Form1.ListBox1.Items.Item(a).ToString)
Next

If you want to add textbox's text of from1 to listbox1 of Form2

write the below codes in form2_load event....

ListBox1.Items.Clear()
ListBox1.Items.Add(Form1.textbox1.text.ToString)
ListBox1.Items.Add(Form1.textbox2.text.ToString)
ListBox1.Items.Add(Form1.textbox3.text.ToString)
ListBox1.Items.Add(Form1.textbox4.text.ToString)
ListBox1.Items.Add(Form1.textbox5.text.ToString)
P.manidas 39 Posting Whiz in Training

Already mentioned "before loading and updating"

old_product.Items.clear()
old_model.Items.clear()
 While sdr.Read()
     old_product.Items.Add(sdr.Item("product").ToString)
     old_model.Items.Add(sdr.Item("model").ToString)
End While
P.manidas 39 Posting Whiz in Training

You need to clear the data from both the combobox before loading and updating data of the combobox like this..

old_product.Items.clear()
old_model.Items.clear()
P.manidas 39 Posting Whiz in Training

You need four digit number after "MR/IR/", so you have to keep your field like MR/IR/0001, MR/IR/0002 .... MR/IR/0997, MR/IR/0998 then it will increase to MR/IR/0999, MR/IR/1000, MR/IR/1001 so on, up to MR/IR/9999.

If you keep your filed MR/IR/001, MR/IR/002 -- MR/IR/999. It will give error like "Argument length must be greater or equal to zero".

see it and check it.

P.manidas 39 Posting Whiz in Training

You have to change the filed data MR/IR/001 --- MR/IR/999 to MR/IR/0001 -- MR/IR/0999 in your database then my codes will works. --- for first 2 line changer code

you can check by changing the last records filed MR/IR/999 to MR/IR/0999

And same as for three line changer also...

P.manidas 39 Posting Whiz in Training

Dear Igho,

I have tested and it works fine.

If you need counter MR/IR/0001 to MR/IR/9999

Try this codes as i modify two lines ....

dtReader = cmd.ExecuteReader
If dtReader.Read Then
strTemp = Mid(dtReader.Item("IDPERIKSA"), 7, 4)

Else
'TxtDETAILTRANS.Text = "MR/IR/001" 
TxtDETAILTRANS.Text = "MR/IR/0001" 'change here
Exit Sub
End If
msgBox(strTemp)
strValue = Val(strTemp) + 1
'TxtDETAILTRANS.Text = "MR/IR/" & Mid("000", 1, 3 - strValue.Length) & strValue 
 TxtDETAILTRANS.Text = "MR/IR/" & Mid("0000", 1, 4 - strValue.Length) & strValue ' change here

or If you need counter MR/IR/00001 to MR/IR/99999

Try this codes as i modify three lines....

dtReader = cmd.ExecuteReader
If dtReader.Read Then
'strTemp = Mid(dtReader.Item("IDPERIKSA"), 7, 4)
strTemp = Mid(dtReader.Item("IDPERIKSA"), 7, 5) ' change here

Else
'TxtDETAILTRANS.Text = "MR/IR/001" 
TxtDETAILTRANS.Text = "MR/IR/00001" 'change here
Exit Sub
End If
msgBox(strTemp)
strValue = Val(strTemp) + 1
'TxtDETAILTRANS.Text = "MR/IR/" & Mid("000", 1, 3 - strValue.Length) & strValue 
 TxtDETAILTRANS.Text = "MR/IR/" & Mid("00000", 1, 5 - strValue.Length) & strValue ' change here
P.manidas 39 Posting Whiz in Training

Dear Androidz,

I had also started a thread as similar as to your thread. I have got the result. Probably you will also get the result from that. The thread is :

Addition of number from dynamically created textboxes after inputted by user

P.manidas 39 Posting Whiz in Training

I have got the result/solution from Microsoft Visual Basic Developer Center. The answer has given by respected sir "Calle Mellergardh". And the codes are ...

Private Sub AddFromCreatedTextBox_Click()
'what will be the codes here
Dim ctl As Control
    Dim num As Integer
    Dim total As Integer
   
    For Each ctl In Me.Controls
        If TypeOf ctl Is TextBox And InStr(ctl.Name, "TxtBox") <> 0 Then
            num = Val(Trim(ctl.Text))
            total = total + num
        End If
    Next
    MsgBox total
End Sub
debasisdas commented: thank you for shairing. +9
P.manidas 39 Posting Whiz in Training

Dear Luc001,

Thanks for replying sir, but i was not asking for data binding as i had mentioned earlier also. Thanks sir.

Dear SandeepParekh9,

I have done it with my own logic. But off course, it is not good idea because there are few drawback is there. Any way, i have done it. (Codes are attached)

As you had mentioned "practically its possible". Is there other ways, please let me know sir?

dim Myslno as integer=0

Private Sub BtnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNext.Click
        MySlno = MySlno + 1
        ST = "select * from table1 where empno="
        ST = ST + "'" + MySlno.ToString + "'"
        cmd = New OleDbCommand(ST, cn) ' where empno=" + "'" + TextBox1.Text + "'", cn)
        dr = cmd.ExecuteReader()

        dr.Read()
        If dr.HasRows Then
            TextBox1.Text = dr("empno")
            TextBox2.Text = dr("Ename")
            TextBox3.Text = dr("Department")
        Else
            MySlno = MySlno - 1
        End If
        dr.Close()
    End Sub

    Private Sub BtnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrevious.Click
        If MySlno <> 0 Then
            MySlno = MySlno - 1
        End If
        ST = "select * from table1 where empno="
        ST = ST + "'" + MySlno.ToString + "'"
        cmd = New OleDbCommand(ST, cn) ' where empno=" + "'" + TextBox1.Text + "'", cn)
        dr = cmd.ExecuteReader()

        dr.Read()
        If dr.HasRows Then
            TextBox1.Text = dr("empno")
            TextBox2.Text = dr("Ename")
            TextBox3.Text = dr("Department")
        Else
            MySlno = MySlno + 1
        End If
        dr.Close()
    End Sub

    Private Sub BtnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) …
P.manidas 39 Posting Whiz in Training

Cyndy S,

I have tested the above(JX Man) codes with my own database using little change and its return right answer. However, i have noticed in the line no. 10, "Fields" is missing. I am not sure, it may be worked or may not. But the logic is right. if that code line will not work just change the line as below. it will work 100%.

stBooks.AddItem datBooks.Recordset.Fields("Title").Value

And one thing i want to tell you whenever you go for comparing string always use Trim as well as UCase function on the both side. If you don't use Trim function and if the user will enter the data giving one or more space before or after the data, it will not return right answer even if user entered the right data.

P.manidas 39 Posting Whiz in Training
Private Sub CmdLoadTextBox_Click()
Dim TopPosition As Integer

NoOfControl = Val(Trim(Text1.Text))

    TopPosition = 3000

    For A = 1 To NoOfControl Step 1
        'Here i want to create an object variable (How many, it will depend on
        '"NoOfControl" variable)
        
        Set TxtBox = Me.Controls.Add("vb.TextBox", "TxtBox" + Trim(Str(A)))
        'And here i want to place object(textbox) into new object variable
        'newobjectvariable = object variable (Textbox)
        With TxtBox
            .Left = 3000
            .Top = TopPosition
            .Width = 1000
            .Height = 500
            .Visible = True
            .DragMode = 0
        End With
    
        TopPosition = TopPosition + 1000
    Next A

End If

End Sub

Dear JX Man,

I have posted the sample codes where/why i need the new object variable and storing the object variable into an object variable. Please see my comments on the codes.

I think this information will be enough for you. Thanks for replying sir and waiting

P.manidas 39 Posting Whiz in Training

I am posting whole codes of my project for easy reading. And if somebody want to see the project with form and control please download the attachment from my above post.

Dim WithEvents TxtBox As TextBox
Dim WithEvents LblLabel As Label
Dim NoOfControl As Integer
Dim A As Integer

Private Sub AddFromCreatedTextBox_Click()
'what will be the codes here
End Sub

Private Sub CmdLoadTextBox_Click()
Dim TopPosition As Integer

NoOfControl = Val(Trim(Text1.Text))

If NoOfControl <= 7 Then
    TopPosition = 3000

    For A = 1 To NoOfControl Step 1
    
        Set LblLabel = Me.Controls.Add("vb.Label", "DLabel" + Trim(Str(A)))
        With LblLabel
            .Left = 500
            .Top = TopPosition
            .Width = 2000
            .Height = 700
            .Visible = True
            .Caption = "Enter Number on Text Box"
            .DragMode = 0
        End With
    
        Set TxtBox = Me.Controls.Add("vb.TextBox", "TxtBox" + Trim(Str(A)))
        With TxtBox
            .Left = 3000
            .Top = TopPosition
            .Width = 1000
            .Height = 500
            .Visible = True
            .DragMode = 0
        End With
    
        TopPosition = TopPosition + 1000
    Next A

Else
    MsgBox "You can't create here more than 7 controls"
    Exit Sub
End If

End Sub
P.manidas 39 Posting Whiz in Training

In addition to my previous reply. Try changing the 9 nos. line of your original post as below....

If Trim(UCase(datBooks.Recordset.Fields("Author").Value)) = Trim(UCase(strSearchFor)) Then
P.manidas 39 Posting Whiz in Training

Place the move next line(14 nos. line on your codes) once again for going to the next record after matching your query. See the modification codes

Do While (Not foundFlag) And (Not datBooks.Recordset.EOF)
    If UCase(datBooks.Recordset.Fields("Author").Value) = strSearchFor Then
      foundFlag = True
      lstBooks.AddItem datBooks.Recordset.Fields("Title").Value
      'Here also place move next for go to next record after matching your query
      datBooks.Recordset.MoveNext 'add new line
      Else
      datBooks.Recordset.MoveNext
    End If
  Loop
P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

I want to know two things here..

1. Can we create object variable on Run time?
2. Can we store one object variable's data (Object) into another object variable?

Please guide me sir/madam. Because, i have no idea in this regard.

P.manidas 39 Posting Whiz in Training

Dear SandeepParekh9,

Thanks for replying again sir, that means we can't specify the record position by using those two. If it is right then it will not be good idea for using OledbCommand and OledbDataReader to display next or previous... records.

P.manidas 39 Posting Whiz in Training

Dear Debasisdas,

Androidz has not got any solution yet.