P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

I have created a sample program that dynamically created up to 7 numbers of Labels and Text Boxes. Here I want to add those numbers inputted by user on dynamically created text boxes. I have tried a lot but all are in vain. Please guide me to solve this problem.

I have attached my test program.

P.manidas 39 Posting Whiz in Training

Dear Debasisdas and SandeepParekh9,

Thanks for replying once again. Actually, i have not asked for data binding here on my original question. I have just asked for displaying next, previous,..... records using OleDBCommand and OleDBDataReader.

Although, all the information mentioned by you, will also help me when i will go for databindig. Thanks for that.

P.manidas 39 Posting Whiz in Training

Dear SandeepParekh9,

Thanks for replying sir, may be both the link are nice example as pointed out by respected member Debasisdas but for me it is hard to understand because i am totally new in VB.net language. I have no idea about currency manager, Binding Context, data binding etc.

However, i am trying to understand to find out the solution as per my requirement.

Earlier I have done it using DBCommandbuider, DataAdapter, Datatable, Dataset etc. But when i have tried it using dataReader and DBcommand i am getting pause. Because i am not getting the logic/Command how to or where to use the row_Position for moving next or previous record.

Sir, if any other solution is there please guide me again.

P.manidas 39 Posting Whiz in Training

Let me see your codes first.

P.manidas 39 Posting Whiz in Training

Dear sir/Madam,

In my codes CmdDisplay button display only first record from the table and button2 add the all name (Ename field) to combobox1 from the table. How can i show FirstRecord, PreviousRecord, NextRecord and LastRecord using OleDbCommand and OleDBdataReader. Please guide me.

Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\emp.mdb;")
        cn.Open()
End Sub



Private Sub CmdDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdDisplay.Click

cmd = New OleDbCommand("select * from table1", cn)
dr = cmd.ExecuteReader()

If dr.Read() = True Then
	TextBox1.Text = dr("empno")
	TextBox2.Text = dr("Ename")
	TextBox3.Text = dr("Department")
End If

End Sub


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
cmd = New OleDbCommand("select * from table1", cn)
dr = cmd.ExecuteReader()

Do While dr.Read()
	ComboBox1.Items.Add(dr("ename"))
Loop
End Sub
P.manidas 39 Posting Whiz in Training

This is an example with listbox for getting your solution. Hope, it will solve your problem.

Dim A As Integer = 0

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        A = A + 1
        If Trim(TextBox1.Text) = Trim(Now) Then
            ListBox1.Items.Add(Now & " " & A)
        Else
            A = 1
            ListBox1.Items.Add(Now & " " & A)
        End If
        TextBox1.Text = Now
    End Sub
swathys commented: thank you +0
P.manidas 39 Posting Whiz in Training

Dear CodeOrder and Luc001,

Thanks for replying with right answer. It has solved my thread.

And thank you all for replying to my thread.

P.manidas 39 Posting Whiz in Training

Dear Animal Mother,

Hiding my form1 (first form) and as you told, hiding first form completely for closing and showing other form is more or less same. Actually, i want to free the complete memory which is taking by form1. Anyway, thanks for your suggestion sir.

Dear Vanzhyme,

Thanks for replying sir, but sorry, right now I don't want to use IsMDIContainer. Any other suggestion sir?

P.manidas 39 Posting Whiz in Training

Dear Animal Mother,

Thanks for replying sir, Hiding and making visible = False, i can do that as i have mentioned in my thread also. May be it is not possible for closing form1 after loading/showing form2. Because it is possible in VB 6.0. I just want to know that things.

P.manidas 39 Posting Whiz in Training

Dear Adatapost,

Thanks for replying sir, i understand that i can't access the members of current form using "Default Form Instance" name. My question is that can't we close the form1 after showing the form2? And when i use me.close in form1 (as i have mentioned earlier) the whole program is closing.

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

I have two form in my application form1 and form2. Here, i want to show the form2 from form1 by using a button. And i want to reverse back to my form1 from form2 using same technique. But i want to close form1 (Not visible=false or hide) after loading form2 and same thing in reverse back also.

I have tried like this....

'for from1
form2.show()
'form1.close ' not accepted
me.close

In my above code whole application is closing.

'for form2
form1.show()
me.close()

Here it is working in form2

I want to know that can we close our current form after showing another form? Please guide me.

P.manidas 39 Posting Whiz in Training

Whin Lopez, As the code of Vanzhyme worked for you, mark this thread as solved, found at the bottom of this page.

P.manidas 39 Posting Whiz in Training

Satti, in my earlier reply i have told you to use my code in the lostfocus of keydown event of txtExpense3 textbox but you use in text1 and text2's change event. Not like that. Use these whole code.

after using these code reply again. I am in Online.

Private Sub txtExpense3_LostFocus()
Text2.Text = Val(txtCommision.Text) + Val(txtRent.Text) + Val(txtLabour.Text) + Val(txtReturnExpense.Text) + Val(txtExpense2.Text) + Val(txtStoreExpense.Text) + Val(txtPhoneExpense.Text) + Val(txtExpense3.Text)
Text1.Text = Val(txtNetPrice) - Val(Text2.Text)
End Sub
P.manidas 39 Posting Whiz in Training

Write down the below code in the text field's (txtexpense3) lostfocus or keydown event. In your code txtexpense3 is written as txtexpemse3

Text2.Text = Val(txtCommision.Text) + Val(txtRent.Text) + Val(txtLabour.Text) + Val(txtReturnExpense.Text) + Val(txtExpense2.Text) + Val(txtStoreExpense.Text) + Val(txtPhoneExpense.Text) + Val(txtExpense3.Text)
Text1.Text = Val(txtNetPrice) - Val(Text2.Text)
P.manidas 39 Posting Whiz in Training

Dear Sir,

Thank you all sir for being with me to get the result (may be not with the tooltip or pop up menu) with textbox. I am going to close this thread here. if somebody will get more information about tooltiptext please, please, please send PM to me.

AndreRet sir, your modification is looking good. Thank you sir.

And Thank you all once again.

P.manidas 39 Posting Whiz in Training

Dear Sir,

Sir, i am not going to give up for not getting solution. I am trying myself also. As per discussion with all of you sir that displaying list item in pop up menu will not be convenient for me. And we can display the list item in label or textbox or in the command button (I have done with command button).

(I have attached a test programe using these three controls)

Here, i am getting 100% solution using all these three controls. As i have mention earlier about displaying list item, my first choice is Tool Tip Text. So, i was started in my previous thread asking like "ToolTipText on pressing up or down arrow key in a ListBox".

I think that is also possible, problem is that i am not getting the idea.

I have started my previous thread because i have seen in the windows explorer of Microsoft XP that we can see the file name, type of file, date of modification and size of file as tool tip text (It may be other but it look like a tool tip text) on moving my mouse cursor to the file or pressing arrow key up or down by selecting the file.

Moreover, if the list item's length is long and some portion of that not visible then we need to show that list item some where.

As i have seen in the Windows Explorer so, i thought …

P.manidas 39 Posting Whiz in Training

Dear Trilok31,

You are right sir, Thanks for modification. I think, now ben25x has got the solution for his thread. Thanks...

P.manidas 39 Posting Whiz in Training

Dear Sir,

Thanks for replying sir, "LstName" is the name of pop up menu. In my previous thread also some respected member suggested to use label. But my requirement is not that actually. I think i will not get the appropriate answer here. Any way, thank you once again sir.

P.manidas 39 Posting Whiz in Training

Try this one....

Creating a button

Private Sub Form_Load()
Dim Com As CommandButton
Set Com = Me.Controls.Add("vb.commandbutton", "BtnName")

    With Com
        .Left = 1000
        .Top = 3000
        .Width = 5000
        .Height = 1000
        .Visible = True
        .Caption = "My Button"
    End With
End Sub

Moving a button.....

Dim CmdX As Long
Dim CmdY As Long
Dim MoveBtn As Boolean


Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
CmdX = X
CmdY = Y
MoveBtn = True
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MoveBtn Then
    Command1.Top = Command1.Top - (CmdY - Y)
    Command1.Left = Command1.Left - (CmdX - X)
End If
End Sub

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveBtn = False
End Sub
P.manidas 39 Posting Whiz in Training

My previous thread is here

P.manidas 39 Posting Whiz in Training

Then, you want to put all invisible (items out of bounds of list box) items in popup menu?

If this is point, why not put columns in list box?

Also how big will be popup window?
popup and List-box sizes are almost same size, so i do not thing that you will gain space using popup and not enlargeing listbox. Except on small forms.

Dear Sir,

I have no idea about putting culumns in list box. And popup should be long as the list item.

Actually my first choice was ToolTipText as i have asked in my previous thread. But i have not succeed on that. Please see my previous thread.

P.manidas 39 Posting Whiz in Training

Then, you want to put all invisible (items out of bounds of list box) items in popup menu?

If this is point, why not put columns in list box?

I am not clear sir, what you have asked, for more clearance...

Suppose, i have four items in the list box as.....

1. Then, you want to
2. put all invisible
3. If this is point
4. If this is point, why not put columns in list box

Here 1 to 3 will be visible in my list box because these are 3 to 4 words long list item. But in the no. 4 list item 11 nos. of words are there. May be i can visible only 4 nos. words, not all the words in that line.

P.manidas 39 Posting Whiz in Training

In a timer with say an interval of 1000, the following -

mnuPopup.Visible = False

Not working sir.

P.manidas 39 Posting Whiz in Training

I need some clarification...
Pop up menu show when you push up/down arrow in listbox?
What is the point of using Popup when you already see item in list?
Also Popup menu is kind-of modal form, out of focus turns visible to off

If my list box item is too long, and that is not visible in my list box because of list box width.

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

I have used Pop Up menu to show the list_Item of a list box on Up and Down Arrow KeyPressed event. But here i can't see the list item continuously by pressing up or down keys, either i have to click/enter on that pop up menu or in the form to see the next list_item. How can we see the list item continuously by pressing up or down arrow keys. Please guide me.

If KeyCode = vbKeyDown Then
      If List1.ListIndex = List1.ListCount - 1 Then
      List1.Selected(List1.ListIndex) = True
      LstName.Caption = List1.Text
      PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
      ElseIf List1.ListIndex = -1 Then
      List1.Selected(List1.ListIndex + 1) = True
      LstName.Caption = List1.Text
      PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
      List1.Selected(List1.ListIndex) = False
      Else
      List1.Selected(List1.ListIndex + 1) = True
      LstName.Caption = List1.Text
      PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
      List1.Selected(List1.ListIndex - 1) = True
      End If
      ElseIf KeyCode = vbKeyUp Then
      If List1.ListIndex = List1.TopIndex Then
      List1.Selected(List1.ListIndex) = True
      LstName.Caption = List1.Text
      PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
      ElseIf List1.ListIndex = -1 Then
      List1.Selected(List1.ListIndex + 1) = True
      LstName.Caption = List1.Text
      PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
      'List1.Selected(List1.ListIndex) = False 
      Else
      List1.Selected(List1.ListIndex - 1) = True
      LstName.Caption = List1.Text
      PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
      List1.Selected(List1.ListIndex + 1) = …
P.manidas 39 Posting Whiz in Training

I am going to close this thread here, because, it has solved using Command Button control as per my requirement but not with the tooltiptext or popup menu.

I am going to open a new thread regarding popup menu as per suggestion of AndreRet.

P.manidas 39 Posting Whiz in Training

why don't you try this...

1. put a label control and keep incrementing its top position from the list top position and keep displaying ur list items.
2. put a timer pause for 5-10 sec...if no key is pressed blank the label caption.

Dear Sir,

Thanks for replying sir, i have already checked with label and i have left that concept because as i know we can't use label over the listbox. Thanks.

P.manidas 39 Posting Whiz in Training

Dear DebasisDas,

Still, I have not marked this thread as solve. If you have better ideas or codes please let me know that sir. I am eagerly waiting for that. Thanks for replying sir.

P.manidas 39 Posting Whiz in Training

Dear AndreRet,

This time i have done it 100% as i wanted, but with the Command Button control. Can we do it with the pop up menu sir. Please check out the attachment, how i have done it.

P.manidas 39 Posting Whiz in Training

Dear AndreRet,

Thanks for your tutorial sir, I have solve 90% from that. But this 10% has halted me. I have tried a lot but all are in vain. Here i can't key down or up continuously, either i have to click/enter on that pop up menu or in the form. I want to see that list of item of list box pressing only down or up arrow key continuously as we can see in our windows explorer.

If KeyCode = vbKeyDown Then
    If List1.ListIndex = List1.ListCount - 1 Then
        List1.Selected(List1.ListIndex) = True
        LstName.Caption = List1.Text
        PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
    ElseIf List1.ListIndex = -1 Then
        List1.Selected(List1.ListIndex + 1) = True
        LstName.Caption = List1.Text
        PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
        List1.Selected(List1.ListIndex) = False
    Else
        List1.Selected(List1.ListIndex + 1) = True
        LstName.Caption = List1.Text
        PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
        List1.Selected(List1.ListIndex - 1) = True
    End If
ElseIf KeyCode = vbKeyUp Then
    If List1.ListIndex = List1.TopIndex Then
        List1.Selected(List1.ListIndex) = True
        LstName.Caption = List1.Text
       PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
    ElseIf List1.ListIndex = -1 Then
        List1.Selected(List1.ListIndex + 1) = True
        LstName.Caption = List1.Text
        PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
        'List1.Selected(List1.ListIndex) = False 'this line not neccessary, putting only for understanding
    Else
        List1.Selected(List1.ListIndex - 1) = True
        LstName.Caption = List1.Text
        PopupMenu MnuPopup, , List1.Left + List1.Width …
P.manidas 39 Posting Whiz in Training

Dear AndreRet,

Thanks for quick reply sir, Is that pop up menu sir, I know something about pop up menu. But i have to try that. Can we show pop up menu as like as toottiptext?

P.manidas 39 Posting Whiz in Training

Dear Debasisdas and AndreRet,

I can see the tooltip in windows explorer by pressing down or up arrow key. As i have attached the picture of that where two tooltips are visible, one is retrieving by pressing arrow keys and other is by cursor. Here i have shown two tooltips because, in the screen shot cursor is not visible. Actually i want to show that cursor is not in the portion where my files are listed.

Anyway, i have seen in the window explorer. So, i thought it is possible to retrieve tooltip in VB 6.0 also by pressing arrow keys. Is it not possible?

Moreover i am trying to do as Debasisdas had said. And AndreRet sir, will it be convenient to show the tooltip in Msg Box, because we will have to close the Msg Box every time.

It will be good if we can see the listItem as tooltiptext by pressing Down or Up Arrow Key.

Thanks for replying sir.

P.manidas 39 Posting Whiz in Training

Dear AndreRet and Jx Man,

Thanks for replying but the Codes are not working. Here, i can see when i down or up arrow key and equally i have to little move my cursor over listbox then i am getting the result. And that result i am getting with my code also without using your codes. I need the result without moving the cursor. Thanks.

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam

I am getting the list item of a listbox as ToolTipTest on mouse move event. How can I get the list item of a listbox as ToolTipTest by pressing Up or Down Arrow Key on KeyBoard. Please guide me.

How i have got the list item as ToolTipText on mouse move i have attached herewith the code for better understanding of my thread.

Private Sub Form_Load()
'List1.Sorted = True in design mode
List1.AddItem "Pankaj"
List1.AddItem "Jayanta"
List1.AddItem "Ramesh"
List1.AddItem "Jonali"
List1.AddItem "Karna"
List1.AddItem "Dilip"
List1.AddItem "Rajkumar"
List1.AddItem "Sankar"
End Sub

Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
List1.ToolTipText = List1.Text
End Sub
P.manidas 39 Posting Whiz in Training

dear Sir/Madam,

I am unable open the regedit and showing the message that "Registry editing has been disable by your Administrator" though i am logging in as an Administrator. I have tried lots of technique but all are in vain. I have tried these ....

1.http://www.techtipsgeek.com/re-enable-registry-editor-disabled-virus/4392/

2. Registryfix.exe

3. Restore point date is not available in my PC

Please guide me for solving this problem because i am unable to installed Anti Virus Software too.

P.manidas 39 Posting Whiz in Training

Dear AndreRet,

Your information is valuable for me sir and thanks for being with me for solving this question. Still I am keeping all my hair in original state. It may be happen as you said for my other question :), because i am trying heard for getting solution.

Thank you once again for appreciating me.

P.manidas 39 Posting Whiz in Training

Dear AndreRet,

Sir, i have got another solution for checking execution time of a procedure. This time i have got the solution in fraction without using timer.

Private Sub Command1_Click() 'without timer its successfull
Dim ST As Double
Dim FT As Double
ST = Timer
For a = 1 To 1000000 Step 1
    Label1.Caption = Val(Label1.Caption) + 1
Next
FT = Timer
Text1.Text = "Total time required by this procedure is " + Str(FT - ST) + " Seconds"
End Sub
AndreRet commented: Nice! +6
P.manidas 39 Posting Whiz in Training

Dear AndreRet,

As i have seen in the firt part of your program, result is showing the time of clicking inbetween Enable timer first(Cmd3) to

Stop Timer(cmd1) button.

In the second part, result is showing the same but here you have done summation of seris of clicking inbetween Enable timer

first(Cmd4) to Stop Timer(cmd2) button.

But i am not getting the result as i want. May be i am not getting the logic as you are thinking.

I think you are cleared what i want. However, i am once again putting my requirement.

I want to measure the time require by a long procedure from first line to last line that may be 1000 lines of codes or few

loop and elseif statement as i have puted a loop in my test program (1 To 1000000). I want to see the time how many seconds are taking by that procedure or other procedure

In my test program command1(First Test) button showing the result as starting and ending time of procedure. Where i can see the difference as 10 seconds in my PC (Pentium 4). And that test has been done without taking the help of timer.

In the Command2(second test) and Command3(third test), i have used timer but result has not got. And i have seen when i cliked on all three button one by one timers controls are pausing when commands are running.

Thanking you once again.

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam

How to check execution time of a procedure with the help of Timer control? How i have tried, i am attaching herewith my test program. Please guide me.

P.manidas 39 Posting Whiz in Training

Dear AndreRed,

I have a program to make a Calendar on Excel Sheet. Where Calendar year will be chosen by user and giving his own/office holiday list.

On that program the main procedure is taking few time for fully executing. I have tried as Dbasisdas said and after that i have got, the procedure is taking 1 to 10 seconds. Execution time is very machine to machine. And it's OK.

As you have pointed out, i am bound to agree with you, though i have got the result by using system time. Problem is that i am not getting the result using timer. I have tried like this........

1st one ----------------
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Val(Label1.Caption) + 1 '1 is equal to 0.1 second
End Sub

Private Sub Command1_Click()
Timer1.Enabled = True
'my all codes here
Timer1.Enabled = False
End Sub

here timer1 is not working or label1's caption(number) not increasing


2nd one --------------------
Dim cnt As Integer
Dim TM1 As Integer

Private Sub Form_Load()
cnt = 0
TM1 = 0
Timer1.Interval = 100
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
cnt = cnt + 1
End Sub

Private Sub Command1_Click()
cnt = 0
'my all codes here
TM1 = cnt

P.manidas 39 Posting Whiz in Training

Dear AndreRet,

Thanks for your reply. I have tried with timer earlier also but that was not worked. Anyway thanks for your reply.

Dear Debasisdas,

Thanks for your simple but excellent logic which has worked for me. And for your kind information both the procedure has taken same time.

Thank you all

P.manidas 39 Posting Whiz in Training

Execution time is independent of lines of code.
It may happen that a procedure has 1000 lines of code because of a long running IF ELSE but the line 10 to 1000 never gets executed.

It depends on what the code is actually doing.

Thanks for replying, but i need the method or technique how to check the time required for those procedure.

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

I have two types of procedure for one/same result. No. 1 procedure is very long without loop and no. 2 procedure is sort with many loops. So I want to check those procedure, which one is taking less time than another.

Please guide me.

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

I want to draw a word/sentence over form by coding as like as pencil is drawing in Paint Programe. But in Paint Programe Pencil is handle by user, here i want it to draw automatically. (like somebody is writing his name by Pen/Pencil)

Please guide me.

P.manidas 39 Posting Whiz in Training

Think left and think right and think low and think high. Oh, the thinks you can think up if only you try ! - Dr. Seuss

P.manidas 39 Posting Whiz in Training

No problem.

P.manidas 39 Posting Whiz in Training

Dear vb5prgrmr,

Thank you for your reply with lot more information. It's really help me.

Thank you vary much.

P.manidas 39 Posting Whiz in Training

Time to use your friends (yahoo, google, ask, answers, bing) and search for vb6 ReadProcessMemory or you could use the task manager to see how much your program takes up in memory...

Good Luck

Dear vb5prgrmr,

First of all thanks for your reply, vb4prgrmr.

As you have written, i have seen in the Task Manager regarding memory used by the programe. If it shows perfect result, then it's OK.

And what about the precaution to take at design time for less memory consumption by the programe/software? And rest of all i will search with my friend as you have written.

Thank you

P.manidas 39 Posting Whiz in Training

Hi P.manidas,
What type of memory you want to read/measure? Do you mean to say Memory used for storing or memory used while running your program?

Thanks

Dear Kinwang2009,

Here i am asking about 2nd one. How much memory will be consumed at the time of running the programe.

Thank you for your query.

P.manidas 39 Posting Whiz in Training

Dear Sir/Madam,

How to measure memory consumption of a VB 6.0's programe?

As a programmer in vb. 6.0, where i have to be conscious for getting less consumption of memory of my program at design time?

Is there any free software to measure memory consumption of a programe?

Please guide me Sir/Madam