getting data through the notepad

how can i get the data into the notepad

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

38 Replies - 10326 Views - Last Post: 03 September 2010 - 01:48 AM Rate Topic: -----

#1 Guest_kisukekawaii*


Reputation:

getting data through the notepad

Posted 22 July 2010 - 05:42 AM

in my notepad have a data.....

for example:

this is our data
mobile no. minutes
09276945845# 1808 353606 008 0
09276945845# 1808 353606 006 0
09276945845# 1808 353606 005 0
09175518449# 1017 349421 008 0
09175518449# 1079 349421 008 0
09179405935# 1072 349421 007 0
09276945845# 1808 353606 005 0
09175518449# 1017 349421 006 0
09392094781# 1017 339786 003 0

visual basic 6 program....

in the textbox i want to search the 4 digit and getting the total number of minutes of the same 4 digits..... when i click the command the result is the total number of minutes.....

so if i search 0927, all 0927 is to compute the total minutes 8+6+5+5= 24mins

if i search 0917 , all 0917 is to compute the total minutes 8+8+7+6=28mins



i have no idea how to start this program....

i hope you help me of my project

thanks

Is This A Good Question/Topic? 0

Replies To: getting data through the notepad

#2 raziel_   User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,281
  • Joined: 25-March 09

Re: getting data through the notepad

Posted 22 July 2010 - 07:01 AM

look at our tutorial and snippet sections there is a tutorials about how to read a text file. and using instr() function you can find string within a string. :)

Tutorials
Snippets
Was This Post Helpful? 0
  • +
  • -

#3 thava   User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,607
  • Joined: 17-April 07

Re: getting data through the notepad

Posted 22 July 2010 - 07:12 AM

hopefully but use the links


ado and textfile
Was This Post Helpful? 0
  • +
  • -

#4 ram11   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 86
  • Joined: 30-November 08

Re: getting data through the notepad

Posted 22 July 2010 - 10:24 PM

{CODE REMOVED}

We do not do peoples homework or coding work for them
We are a help community, not a ready made code service. We have
no problems helping anyone as long as they show they're willing
to put forth the effort to actually learn something.


This post has been edited by PsychoCoder: 22 July 2010 - 10:42 PM
Reason for edit:: Code removed

Was This Post Helpful? 0
  • +
  • -

#5 bytelogik   User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 218
  • Joined: 06-October 09

Re: getting data through the notepad

Posted 26 July 2010 - 02:32 AM

Use InStr() to search for your 4 digit code, e.g

use file handling functions to read the file.

dim celldata() as string
If InStr(CellNumber,"DigitCode")<> 0 then
'now use split function to separate minute value
celldata=split(CellNumber)
minutes=minutes+val(celldata(3))

end if

you need to write at least a "try program".
Was This Post Helpful? 0
  • +
  • -

#6 Guest_kisukekawaii*


Reputation:

Re: getting data through the notepad

Posted 26 July 2010 - 03:04 PM

@bytelogik

i will try my best to do my project can u help me when i show you my code to edit or change...? :D
Was This Post Helpful? 0

#7 ram11   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 86
  • Joined: 30-November 08

Re: getting data through the notepad

Posted 26 July 2010 - 10:01 PM

lmao PsychoCoder i never saw u help ppl lol , you say ppl should show some effort i had seen many of post where ppl show some effort by posting there code but still u never help them, in fact that time u point out some other small silly mistake but i never seen u helping ppls...lol and please dnt say me abt the reputation point, which u had told me before , i think you get those point by posting forum rulez lol.... and thats my wish if i want to help anyone i am giving my time....
Was This Post Helpful? 0
  • +
  • -

#8 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: getting data through the notepad

Posted 26 July 2010 - 10:04 PM

What the?? Believe it or not (that's up to you) I have helped a ton of people in my time here on Dream.In.Code, and honestly I :

  • Have no idea who you are
  • Have no idea what in the blue hell you're talking about
  • Could care less about points #1 and #2


Honestly, what the hell are you talking about, right now I think you're just some crazy stalker type lunatic :)

EDIT: A crazy stalker type lunatic who's probably pissed because there was an instance where I wouldn't just write your code for you
Was This Post Helpful? 0
  • +
  • -

#9 ram11   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 86
  • Joined: 30-November 08

Re: getting data through the notepad

Posted 26 July 2010 - 10:45 PM

Well you edit & remove my code which i post , dats not fare to delete my post without my permission, bcz i had not post anything wrong which was against forum rulez, i was helping , so as a admin u did wrong by editing my post..
Was This Post Helpful? 0
  • +
  • -

#10 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: getting data through the notepad

Posted 26 July 2010 - 11:21 PM

Well you handed someone source code when they did nothing but ask someone to give them code for something, and that does violate the rules of this community and if you were to do it again I'd remove the code again. We're not a homework service, we're not a code writing service, we're here to help those who are actually wanting to learn something and not just have it handed to them.

If you dont like rules like that then maybe this community isn't the one for you. I'm sure there are tons of them out there that would just let you do peoples homework until your hearts content.

Quote

bcz i had not post anything wrong which was against forum rulez, i was helpin


No you weren't helping, you were spoon feeding someone too lazy to put forth any effort and just wanted someone to do it for them. That does violate many rules of this community

Quote

Well you edit & remove my code which i post , dats not fare to delete my post without my permission


When you violate the rules of this community I dont need your permissions to edit your post in the way it was edited and had the code removed. For that I'm afraid I dont need your permissions
Was This Post Helpful? 0
  • +
  • -

#11 Guest_kisukekawaii*


Reputation:

Re: getting data through the notepad

Posted 27 July 2010 - 12:25 AM

i already open the notepad to the textbox1....
but the problem now is to search button to the textbox in 4digits of cell number and to compute
the total minutes of all the same 4digits in textbox....

this is my code.....


Private Sub cmdOpen_Click()

Dim tmp As String
Dim dis As String
Dim count As String
Dim strToStr As String
Dim lLineCount As Long

nFileNum = FreeFile

Open "C:\Documents and Settings\Administrator\Desktop\SPL_Output_0204095650.txt" For Input As nFileNum
lLineCount = 1
Do While Not EOF(nFileNum)
Line Input #nFileNum, tmp
tmp = tmp & vbTab & vbTab & vbTab

strToStr = strToStr & tmp
Loop
Text1.Text = strToStr
Close nFileNum
End Sub

Private Sub cmdSearch_Click()
Dim celldata() As String
If InStr(CellNumber, "DigitCode") <> 0 Then
'now use split function to separate minute value
celldata = Split(CellNumber)
minutes = minutes + Val(celldata(3))

End If

End Sub




how can i apply the "search command code" to another textbox2 for input 4digits number to search to textbox1

its hard to know the best way to this my project....

i hope you give me some idea or another way to do this....


thanks again......
Was This Post Helpful? 0

#12 bytelogik   User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 218
  • Joined: 06-October 09

Re: getting data through the notepad

Posted 27 July 2010 - 12:57 AM

@Ram:
Not all persons are born with experience. They learn gradually by the environment created by the experienced ones.

@PsychoCoder: (I know you may edit this comment :)
Being an Admin, you have responsibilities. Please don't be harsh on new comers. Thank you.


kisukekawaii,

Nice to see your effort. Congratulations. Problems do not easily break down unless we put our efforts in the right direction.

It seems that you have not enough experience in VB. It's OK if you are new. As you go on programming, you will naturally develop analytical capabilities to solve the toughest problems. It just takes time and hard work.

Now to your problem.

1) You need not get the file contents in the text box. You can perform search function in the file handling sub, i.e., in the cmd_Open()

2) You are getting the line input in the tmp variable. You can analyze this string variable if it contains your four digit code using InStr(). If it is found, then execute the Split() function to extract individual elements which are separated by space. Once splitted, as I see, the third index of the CellData variable should contain your minute value. You then increase your minute duration.

3) Finally, you display your minute duration for your selected 4-digit code.

You may wonder, why I straight away not giving the solution. But then, the spirit of learning inside you will have no value.

Try and let me know what you have done. Post again if you have come across any difficulty.

Good Luck.
Was This Post Helpful? 0
  • +
  • -

#13 Guest_kisukekawaii*


Reputation:

Re: getting data through the notepad

Posted 27 July 2010 - 05:53 AM

@bytelogik

okay i'll try it again just help me and check my work hehe.... :D
just wait and see again :P
Was This Post Helpful? 0

#14 thava   User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,607
  • Joined: 17-April 07

Re: getting data through the notepad

Posted 27 July 2010 - 05:45 PM

View Postram11, on 26 July 2010 - 09:01 PM, said:

lmao PsychoCoder i never saw u help ppl lol , you say ppl should show some effort i had seen many of post where ppl show some effort by posting there code but still u never help them, in fact that time u point out some other small silly mistake but i never seen u helping ppls...lol and please dnt say me abt the reputation point, which u had told me before , i think you get those point by posting forum rulez lol.... and thats my wish if i want to help anyone i am giving my time....


you know ram11 even i can also get help from psycho

you know hurting others like this ??????????
is that your signature say this??????????

you know how much he is helpful watch his active threads count, and friends list

do you know the proverb

Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime


and i post a link to him he just make a try on that, later we will help to him

PsychoCoder cool man we are here and we know how much you are helpful to others

ok
its time to give some help there
copy your file in the name of p.txt and give a empty line in the start of the line like this in a separate folder

Quote

09276945845# 1808 353606 008 0
09276945845# 1808 353606 006 0
09276945845# 1808 353606 005 0
09175518449# 1017 349421 008 0
09175518449# 1079 349421 008 0
09179405935# 1072 349421 007 0
09276945845# 1808 353606 005 0
09175518449# 1017 349421 006 0
09392094781# 1017 339786 003 0

and in that folder save a schema.ini file with the following text
[p.txt]
Format=FixedLength

Col1=mobile Text Width 13
Col2=x Text Width 5
Col3=y Text Width 7
Col4=min Text Width 4
Col5=ID Text Width 1


now see the magic
On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H1

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

strPathtoTextFile = "i:\test"

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source=" & strPathtoTextFile & ";" & _
          "Extended Properties=""text;HDR=No;FMT=FixedLength"""

objRecordset.Open "SELECT * FROM P.txt where mobile like '0927%'  ", _
          objConnection, adOpenStatic, adLockOptimistic, adCmdText
  For x = 1 To objRecordset.RecordCount
        Debug.Print "Mobile: " & objRecordset.Fields("Mobile").Value & _
                        "  Minutes: " & objRecordset.Fields("min").Value
        
        objRecordset.MoveNext
    Next
objRecordset.Close
objRecordset.Open "SELECT sum(val(min)) FROM P.txt where mobile like '0927%' ", _
          objConnection, adOpenStatic, adLockOptimistic, adCmdText
          
MsgBox objRecordset(0)


i think you may now get a start up with this

This post has been edited by thava: 27 July 2010 - 05:46 PM

Was This Post Helpful? 0
  • +
  • -

#15 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: getting data through the notepad

Posted 27 July 2010 - 05:52 PM

bytelogik ram11 has been a member since 2008 so he's not a newcomer and I wasnt being harsh, just honest ;)

thava thanks :)
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3