HELP PLZZZ

When I click on 2 photos a message appears saying "a calling thread cannot access this object because a different thread owns it" I have no clue how to fix this PLZZZ HELP I just started this class so I don't know many key words here is my code
' Match Game
InitializeProgram()
Sub InitializeProgram
'graphics window
GraphicsWindow.Width = 825
GraphicsWindow.Height = 530
GraphicsWindow.BackgroundColor = "LightSkyBlue"
'initialize box locations with covers
Cover = "C:\New folder\gold.png"
BoxW = 150
BoxH = 100
x = 5
y = 5
For I = 1 To 20
BoxX[I] = x
BoxY[I] = y
GraphicsWindow.DrawResizedImage(Cover, BoxX[I], BoxY[I], BoxW, BoxH)
x = x + BoxW + 5
If (x > 4 * BoxW) Then
x = 5
y = y + BoxH + 5
EndIf
EndFor
EndSub
'load images
Photo[1] = "C:\Users\John\Desktop\New folder (2)\gg.jpg"
Photo[2] = "C:\Users\John\Desktop\New folder (2)\ggg.jpg"
Photo[3] = "C:\Users\John\Desktop\New folder (2)\gggg.jpg"
Photo[4] = "C:\Users\John\Desktop\New folder (2)\ggggg.jpg"
Photo[5] = "C:\Users\John\Desktop\New folder (2)\gggggg.jpg"
Photo[6] = "C:\Users\John\Desktop\New folder (2)\ggggggg.jpg"
Photo[7] = "C:\Users\John\Desktop\New folder (2)\gggggggg.jpg"
Photo[8] = "C:\Users\John\Desktop\New folder (2)\ggggggggg.jpg"
Photo[9] = "C:\Users\John\Desktop\New folder (2)\gggggggggg.jpg"
Photo[10] ="C:\Users\John\Desktop\New folder (2)\ggggggggggg.jpg"
Timer.Interval = 1000
Timer.Pause()
Timer.Tick = TickSub
GraphicsWindow.MouseDown = MouseDownSub
Sub MouseDownSub
If (GameStatus = "Playing" And CanClick) Then
'find which box was clicked
x = GraphicsWindow.MouseX
y = GraphicsWindow.MouseY
BoxNumber = 0
For I = 1 To 20
If (x > BoxX[I] And x < BoxX[I] + BoxW) Then
If (y > BoxY[I] And y < BoxY[I] + BoxH) Then
BoxNumber = I
Goto GotIt
EndIf
EndIf
EndFor
GotIt:
If (BoxNumber <> 0) Then
'if already clicked then exit
If (PhotoFound[BoxNumber]) Then
Goto LeaveMouseDownSub
EndIf
ShowPhotoAndCheck()
EndIf
EndIf
LeaveMouseDownSub:
EndSub
'headings
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontBold = "false"
GraphicsWindow.FontSize = 20
Heading[1] = Shapes.AddText("Player 1")
Heading[2] = Shapes.AddText("Player 2")
Shapes.Move(Heading[1], 670, 5)
Shapes.Move(Heading[2], 670, 70)
'scores
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(670, 35, 100, 25)
GraphicsWindow.FillRectangle(670, 100, 100, 25)
GraphicsWindow.BrushColor = "Black"
Score[1] = 0
Score[2] = 0
ScoreDisplay[1] = Shapes.AddText(Score[1])
ScoreDisplay[2] = Shapes.AddText(Score[2])
Shapes.Move(ScoreDisplay[1], 715, 35)
Shapes.Move(ScoreDisplay[2], 715, 100)
'Draw message area
GraphicsWindow.BrushColor = "Yellow"
GraphicsWindow.FillRectangle(630, 250, 185, 45)
GraphicsWindow.PenColor = "Black"
GraphicsWindow.PenWidth = 2
GraphicsWindow.DrawRectangle(630, 250, 185, 45)
GraphicsWindow.BrushColor = "Blue"
GraphicsWindow.FontBold = "false"
GraphicsWindow.FontSize = 18
Message = "Game Stopped"
MessageX = 30
MessageArea = Shapes.AddText(Message)
DisplayMessage()
Sub DisplayMessage
Shapes.Move(MessageArea, 630 + MessageX, 260)
Shapes.SetText(MessageArea, Message)
EndSub
'define buttons
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontSize = 16
StartStopButton = Controls.AddButton("Start Game", 630, 410)
OptionsButton = Controls.AddButton("Change Options", 630, 450)
ExitButton = Controls.AddButton("Exit", 630, 490)
'Default Options
NumberPlayers = 2
PlayAlone = "true"
Difficulty = 1
SetTitle()
GameStatus = "Stopped"
Sub SetTitle
If (NumberPlayers = 1) Then
GraphicsWindow.Title = "Match Game - 1 Player, "
If (PlayAlone) Then
GraphicsWindow.Title = GraphicsWindow.Title + "Play Alone"
Else
GraphicsWindow.Title = GraphicsWindow.Title + "Play Computer"
EndIf
Else
GraphicsWindow.Title = "Match Game - 2 Players"
EndIf
EndSub
Controls.ButtonClicked = ButtonClickedSub
Sub ButtonClickedSub
B = Controls.LastClickedButton
If (GameStatus = "Stopped") Then
If (B = ExitButton) Then
Program.End()
ElseIf (B = OptionsButton) Then
SetOptions()
ElseIf (B = StartStopButton) Then
StartGame()
EndIf
ElseIf (GameStatus = "Playing") Then
If (B = StartStopButton) Then
'stop program
Message = "Game Stopped"
MessageX = 30
StopGame()
EndIf
EndIf
EndSub
Sub SetOptions
GraphicsWindow.Hide()
TextWindow.Show()
TextWindow.Title = "Match Game"
TextWindow.CursorLeft = 3
TextWindow.CursorTop = 3
TextWindow.WriteLine("MATCH GAME OPTIONS")
TextWindow.WriteLine("")
GetPlayers:
TextWindow.CursorLeft = 3
TextWindow.WriteLine("With one player, you play alone or against the computer.")
TextWindow.CursorLeft = 3
TextWindow.WriteLine("With two players, you play against a friend.")
TextWindow.CursorLeft = 3
TextWindow.Write("How many players do you want (1 or 2)? ")
NumberPlayers = TextWindow.ReadNumber()
If (NumberPlayers < 1 Or NumberPlayers > 2) Then
Goto GetPlayers
EndIf
If (NumberPlayers = 1) Then
Heading[1] = "You"
GetPlayAlone:
TextWindow.WriteLine("")
TextWindow.CursorLeft = 3
TextWindow.WriteLine("You can play alone or play the computer.")
TextWindow.CursorLeft = 3
TextWindow.Write("Make your choice (1-Play Alone, 2-Play Computer)? ")
T = TextWindow.ReadNumber()
If (T < 1 Or T > 2) Then
Goto GetPlayAlone
EndIf
If (T = 1) Then
PlayAlone = "true"
Heading[2] = "Guesses"
Else
PlayAlone = "false"
Heading[2] = "Computer"
GetDifficulty:
TextWindow.WriteLine("")
TextWindow.CursorLeft = 3
TextWindow.WriteLine("You can set the game difficulty.")
TextWindow.CursorLeft = 3
TextWindow.Write("Make your choice (1-Easiest, 2-Easy, 3-Hard, 4-Hardest)? ")
Difficulty = TextWindow.ReadNumber()
If (Difficulty < 1 Or Difficulty > 4) Then
Goto GetDifficulty
EndIf
EndIf
Else
Heading[1] = "Player 1"
Heading[2] = "Player 2"
EndIf
SetTitle()
TextWindow.Hide()
GraphicsWindow.Show()
EndSub
GameStatus = "Stopped"
For I = 1 To 10
GraphicsWindow.DrawResizedImage(Photo[I], BoxX[I], BoxY[I], BoxW, BoxH)
EndFor
Sub NRandomIntegers
'Order all elements initially
For I = 1 To N
NIntegers[I] = I
EndFor
'J is the number of integers remaining
For J = N To 2 Step -1
I = Math.GetRandomNumber(J)
T = NIntegers[J]
NIntegers[J] = NIntegers[I]
NIntegers[I] = T
EndFor
EndSub
N = 20
NRandomIntegers()
PhotoIndex = NIntegers
For I = 1 To 20
If (PhotoIndex[I] > 10) Then
PhotoIndex[I] = PhotoIndex[I] - 10
EndIf
EndFor
GraphicsWindow.DrawResizedImage(Photo[PhotoIndex[I]], BoxX[I], BoxY[I], BoxW, BoxH)
Sub KeyDownSub
K = Text.ConvertToUpperCase(GraphicsWindow.LastKey)
If (GameStatus = "Stopped") Then
If (K = "E") Then
Program.End()
ElseIf (K = "C") Then
SetOptions()
ElseIf (K = "S") Then
StartGame()
EndIf
EndIf
EndSub
Sub StartGame
GameStatus = "Playing"
'clear screen
GraphicsWindow.BrushColor = GraphicsWindow.BackgroundColor
GraphicsWindow.FillRectangle(0, 0, 625, 530)
Score[1] = 0
Score[2] = 0
PhotosRemaining = 20
N = 20
NRandomIntegers()
PhotoIndex = NIntegers
For I = 1 To 20
If (PhotoIndex[I] > 10) Then
PhotoIndex[I] = PhotoIndex[I] - 10
EndIf
PhotoFound[I] = "false"
GraphicsWindow.DrawResizedImage(Cover, BoxX[I], BoxY[I], BoxW, BoxH)
EndFor
PlayerNumber = 1
ChoiceNumber = 1
If (NumberPlayers = 1) Then
Message = "Pick a Box"
MessageX = 45
Else
Message = "Player 1, Pick a Box"
MessageX = 10
EndIf
DisplayMessage()
'reset buttons
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontSize = 16
Controls.SetButtonCaption(StartStopButton, "Stop Game")
Controls.HideControl(OptionsButton)
Controls.HideControl(ExitButton)
CanClick = "true"
EndSub
Sub StopGame
'restore buttons
GameStatus = "Stopped"
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontSize = 16
Controls.SetButtonCaption(StartStopButton, "Start Game")
Controls.ShowControl(OptionsButton)
Controls.ShowControl(ExitButton)
CanClick = "false"
DisplayMessage()
EndSub
Sub ShowPhotoAndCheck
'show image behind selected Photo box (BoxNumber)
GraphicsWindow.DrawResizedImage(Photo[PhotoIndex[BoxNumber]], BoxX[BoxNumber], BoxY[BoxNumber], BoxW, BoxH)
PhotoFound[BoxNumber] = "true"
If (ChoiceNumber = 1) Then
Choice[1] = BoxNumber
ChoiceNumber = 2
If (NumberPlayers = 2) Then
Message = "Player " + PlayerNumber + ", Pick Another"
MessageX = 5
DisplayMessage()
Else
'one player logic
EndIf
Else
CanClick = "false"
Timer.Resume()
EndIf
EndSub
Sub TickSub
Choice[2] = BoxNumber
ChoiceNumber = 1
If (PhotoIndex[Choice[1]] = PhotoIndex[Choice[2]]) Then
'a match
Sound.Stop(Program.Directory + "\tada.wav")
Sound.PlayAndWait(Program.Directory + "\tada.wav")
'blank out boxes
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(BoxX[Choice[1]], BoxY[Choice[1]], BoxW, BoxH)
GraphicsWindow.FillRectangle(BoxX[Choice[2]], BoxY[Choice[2]], BoxW, BoxH)
Score[PlayerNumber] = Score[PlayerNumber] + 1
PhotosRemaining = PhotosRemaining - 2
If (PhotosRemaining = 0) Then
Sound.Stop(Program.Directory + "\wow.wav")
Sound.Play(Program.Directory + "\wow.wav")
If (NumberPlayers = 2) Then
If (Score[1] > Score[2]) Then
Message = "Player 1 Wins!"
MessageX = 30
ElseIf (Score[2] > Score[1]) Then
Message = "Player 2 Wins!"
MessageX = 30
Else
Message = "It's a Tie!"
MessageX = 45
EndIf
Else
'one player logic
EndIf
StopGame()
EndIf
'another turn?
If (PhotosRemaining <> 0) Then
If (NumberPlayers = 2) Then
Message = "Player " + PlayerNumber + ", Pick Again"
MessageX = 10
DisplayMessage()
Else
'one player logic
EndIf
EndIf
Else
'no match
Sound.Stop(Program.Directory + "\boing.wav")
Sound.PlayAndWait(Program.Directory + "\boing.wav")
PhotoFound[Choice[1]] = "false"
PhotoFound[Choice[2]] = "false"
GraphicsWindow.DrawResizedImage(Cover, BoxX[Choice[1]], BoxY[Choice[1]], BoxW, BoxH)
GraphicsWindow.DrawResizedImage(Cover, BoxX[Choice[2]], BoxY[Choice[2]], BoxW, BoxH)
'swap players
If (NumberPlayers = 2) Then
If (PlayerNumber = 1) Then
PlayerNumber = 2
Else
PlayerNumber = 1
EndIf
Message = "Player " + PlayerNumber + ", Pick a Box"
MessageX = 10
DisplayMessage()
Else
'one player logic
EndIf
EndIf
CanClick = "true"
EndSub

To debug this we need to do a couple of things which are common to most debugging problems.
1] Add TextWindow.WriteLine statements in lots of places to see exactly where the problem occurs - this will help to write the simple test code to show the issue.  Start by one in the start and end of each Subroutine for example, then add more to identify
the line at which the problem occurs.
Then, if the issue is not clear:
2] Simplify the code as much as possible to show the error - i.e write a simple test program or start from your program and delete bits that are not relevant to your problem.  If you don't need images or sounds in other files to show the problem then
remove them so that some-one else can run the file and see the problem.  If extra images or files are needed to show it, then use test web files, again so the program can be run by some-one else.
Once you do this we can see that the issue is with Sound.Stop().
And a simple test file:
musicFile = "http://litdev.co.uk/game_images/backgroundMusic.mp3"
Sound.Play(musicFile)
Timer.Interval = 5000
Timer.Tick = OnTick
Sub OnTick
Sound.Stop(musicFile)
EndSub
So the problem is that we cannot act on the music with Sound commands from inside an event subroutine - they work on a separate thread to the main UI thread.
Solution: do all work on the main UI thread and only use the event subroutines to set flags:
musicFile = "http://litdev.co.uk/game_images/backgroundMusic.mp3"
Sound.Play(musicFile)
Timer.Interval = 5000
Timer.Tick = OnTick
While ("True")
If (restartMusic) Then
Sound.Stop(musicFile)
Program.Delay(100) 'To hear restart
Sound.Play(musicFile)
restartMusic = "False"
EndIf
Program.Delay(20) 'Don't mash cpu while waiting for input in game loop
EndWhile
Sub OnTick
restartMusic = "True" 'Flag that the music should restart
EndSub
Or more moduar:
musicFile = "http://litdev.co.uk/game_images/backgroundMusic.mp3"
Sound.Play(musicFile)
Timer.Interval = 5000
Timer.Tick = OnTick
While ("True")
CheckRestart()
Program.Delay(20)
EndWhile
Sub OnTick
restartMusic = "True"
EndSub
Sub CheckRestart
If (restartMusic) Then
Sound.Stop(musicFile)
Program.Delay(100) 'To hear restart
Sound.Play(musicFile)
restartMusic = "False"
EndIf
EndSub
For more info see the following wiki articles
http://social.technet.microsoft.com/wiki/contents/articles/15060.small-basic-event-basics.aspx
http://social.technet.microsoft.com/wiki/contents/articles/22264.small-basic-threading.aspx
and for the game loop (While )"True" loop
http://social.technet.microsoft.com/wiki/contents/articles/20865.small-basic-dynamic-graphics.aspx
PS nice program interface by the way - the game loop and event flags is the best way in Small Basic and often in other languages - good luck

Similar Messages

  • HT5312 Every time i try to buy something from the Itunes i cant because i most answer the security question but I don't remember my security question answer help plzzz, note: I can't call the apple support because I live in Saudi Arabi

    Every time i try to buy something from the AppStore  on my iPad or iPhone 4S i cant because i most answer the security question but I don't remember my security question answer, when I try to go change it from my Apple account he ask me the security questions agin and I don't know the answer help plzzz, note: I can't call the apple support because I live in Saudi Arabia

    If you don't see the 'send reset info' button on the page where you can change them then I assume that you don't have a rescue email address (which is not the same thing as an alternate email address) set up on your account. As you won't be able to add one until you can answer 2 of your questions, you will need to contact iTunes Support or Apple to get the questions reset. You could try contacting iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Account Management , and then try Apple ID Account Security

  • Hi i need sum help plzzz, iphone 3gs blackscreen and tryed evrything but wont kick out of dfu mode , much apreicated plz

    hi i need sum help plzzz, iphone 3gs blackscreen and tryed evrything but wont kick out of dfu mode , much apreicated plz, it just happen wen i was restoring  the screen is balck but wen i restore it from itunes it says erorr 1600 and itunes does not reconise the phone , i have tryed eveything bt still no luck , I NEED UR HELP PLZZZ ,its my disabled daughters thank you

    Anyone on this forum can correct me if I am wrong. I am not judging you, but to my knowledge the iTunes error 1600  usually affects products that are  jailbroken. again I am not saying that your iPhone 3GS was jailbroken. my only advise off the top of my head to assist you is to download the recent IOS firmware online. I know it is not the the #1 advised option, but it is the only option you have unless you wish to bring it to the Apple Genius bar and see if they can replace the phone or fix it themselves.

  • I Got an error while trying to download itunes help PLZZZ?!?!?!!?

    Ok when i just got my first ipod touch for my birthday on november 11th. i tried to hook it into itunes but then it says it does not support this device. so then i went onto the website and downloaded itunes 9 it said
    The application has Failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail.
    so after that i was wondering hmm what happen if i deleted itunes then download it and so i did i put it so it runs as administrator and when it was about to finish installing this error comes up.
    an error occurred during the installation of assembly 'microsoft. VC80.CRT, Version ="8.0.50727.4053" ,type = "win32" ,publicKeytToken = '1fc8b3b9a1e3b" ,process orArchitecture ="x86". Please refer to help and support for more information. HRESULT: 0x8007054F.
    It would be very greatfull if someone helped me find a solution. because im getting a little impatient

    I got the same message, followed all the suggestions except turfing vista out the window. HELP would be great

  • Tv tunner help plzzz........

    Hello sir,
    I hav a HP pavilion Entertainment notebook Dv6-1211AX.
    it does not have tv tunner card. but it has a empty slot for it,it also has a empty antina slot near usb slot. Notebook of same catagories were having it (like sub-model, some dv6 1121"TX" were having it).
    i wana intall it, plz help me how can i install it.
    will hp do that, if so wat would be the cost of that......plz help....
    plz also tell that how can i ask hp to install the same.....

    Please refere to the Service Manual regarding your query..
    you will get all information regarding the TV Tuner card at page #55
    ||-Although I am working on behalf of HP, I am speaking for myself and not for HP.-||
    //Click on Kudos if my reply was helpful and answered your question//
    ||-If my answer solved the problem please mark the topic as the accepted solution-||

  • Urgent - - - help plzzz !!!!!!

    HI SAP Gurus,
    I had been asked to create a new project in XML forms builder.
    I had created a project and i have specific two issues there,
    i had created link for email id . when i press the link then i am getting the new window where everytime my name is getting displayed in the body column. In the "TO" Column respected person name is not displayed.
    Guys plz help me.........
    good replies will be rewarded........
    thanks
    regards,
    vijay.

    Hi Vijay,
    That link might have your name as caption. pl check ..else
    you can check this [link|http://help.sap.com/saphelp_nw04/helpdata/en/f3/9d833c0b3e042de10000000a114027/frameset.htm] also.
    Regards,
    Piyush
    Award points if this helps...

  • Create w boutton in cell excel with vbnet help plzzz

    how to create a buttons for ech cell exactly 4 cell (browse) to import a value in cell of excel file (from 4 excel file) imported in datagridview vb net
    all the work at vb net and in the datagridview

    Hi moOTAZ,
    Your question is not clear enough. Please give us some detailed information.
    If you want to use VB.NET application to export the data in DataGridView control to the Excel files, then you have many options.
    1. Use Excel PIA, loop through all the cells in the DataGridView control, get the cell value you want to export, use Microsoft.Office.Interop.Excel namespace to create a new Workbook, add a new Worksheet then save the cell value in this Worksheet. The sample
    code here:
    Dim xlApp As Microsoft.Office.Interop.Excel.Application
    Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook
    Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
    Dim misValue As Object = System.Reflection.Missing.Value
    Dim i As Integer
    Dim j As Integer
    xlApp = New Microsoft.Office.Interop.Excel.ApplicationClass
    xlWorkBook = xlApp.Workbooks.Add(misValue)
    xlWorkSheet = xlWorkBook.Sheets("sheet1")
    For i = 0 To DataGridView1.RowCount - 2
    For j = 0 To DataGridView1.ColumnCount - 1
    For k As Integer = 1 To DataGridView1.Columns.Count
    xlWorkSheet.Cells(1, k) = DataGridView1.Columns(k - 1).HeaderText
    xlWorkSheet.Cells(i + 2, j + 1) = DataGridView1(j, i).Value.ToString()
    Next
    Next
    Next
    xlWorkSheet.SaveAs("D:\vbexcel.xlsx")
    xlWorkBook.Close()
    xlApp.Quit()
    2. Use OleDb to insert data into Excel
    Check the tutorial in this KB article:
    How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET
    3. Use OpenXML SDK if you don't have Excel application installed on the machine
    Manipulating Workbooks using the Open XML SDK
    4. How to import data from Excel to DataGridView control? Check this thread:
    how to import data from excel sheet
    in data grid view using vb.net
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Hey i recently buy an iphone 4s and by default i set it to saudi arabia and i would like to change it to united states since i can't use the apple store of usa any help plzzz

    i recently buy an iphone 4s and by default i set it to saudi arabia and i would like to change it to united states since i can't use the apple store of usa any help plzzz

    Besides setting the iTunes store to the US, you will also need
    a credit card issued in the US with billing address in the US;
    you also are supposed to be located in the US when using the
    US store, and there are periodic software checks to verify that.
    Simply changing the iTunes store to the US iTunes store will
    not allow you to make purchases/download free apps without
    meeting the other requirements. Do you meet them?

  • SQL QUERY HELP PLZZZ

    My requirement is to calculate few things like total_cash_amount,TOTAL_CO_PATIENT_AMOUNT etc... FOr this we will be using BILLING.PATIENTBILL,BILLING.PATIENTBILLDETAILS,BILLING.TRANSACTION tables. The below is already developed procedure.
    I am askd to modify the same for the better performance. The below is the part of it i.e. calculation of total_cash_amount. There will be two categories like INPATIENT(IP) and OUTPATIENT(OP). Can anyone of you please help me to modify the code in a better manner. And can You please suggest whether Global Temporary tables are better or can we use the tables directly.
    INSERT INTO GTT_PATIENTBILL
    SELECT *
      FROM BILLING.PATIENTBILL P
    WHERE P.LOCATIONID = IN_LOCATIONID
       AND TRUNC(P.BILLDATE) BETWEEN TRUNC(IN_YEARDATE) AND TRUNC(IN_FROMDATE);
    INSERT INTO GTT_PATIENTBILLDETAILS  
    SELECT PB.*
      FROM BILLING.PATIENTBILL P, BILLING.PATIENTBILLDETAILS PB
    WHERE P.LOCATIONID = IN_LOCATIONID
       AND P.BILLNO = PB.BILLNO
       AND TRUNC(P.BILLDATE) BETWEEN TRUNC(IN_YEARDATE) AND TRUNC(IN_FROMDATE);
    INSERT INTO GTT_TRANSACTION
    SELECT *
      FROM BILLING.TRANSACTION T
    WHERE T.LOCATIONID = IN_LOCATIONID
       AND TRUNC(T.CREATEDDATE) BETWEEN TRUNC(IN_YEARDATE) AND
           TRUNC(IN_FROMDATE);
    DELETE FROM TEMP_1;
    INSERT INTO TEMP_1
      SELECT (CASE
               WHEN PARTICULARS IS NULL AND FLG = 1 THEN
                'TOTAL COLLECTIONS'
               WHEN PARTICULARS IS NULL AND FLG = 2 THEN
                'TOTAL DEDUCTIONS'
               ELSE
                PARTICULARS
             END) PARTICULARS,
             SUM(A) "FOR THE DAY",
             SUM(B) "MONTH TO DATE",
             SUM(C) "YEAR TO DATE"
        FROM (SELECT PARTICULARS,
                     SUM(TOTAL_CASH_AMOUNT_DAY) A,
                     SUM(TOTAL_CASH_AMOUNT_MONTH) B,
                     SUM(TOTAL_CASH_AMOUNT_YEAR) C,
                     1 FLG
                FROM (SELECT 'OP CASH' PARTICULARS,
                             SUM(P.TOTALSERVICEAMOUNT) TOTAL_CASH_AMOUNT_DAY,
                             0 TOTAL_CASH_AMOUNT_MONTH,
                             0 TOTAL_CASH_AMOUNT_YEAR
                        FROM GTT_PATIENTBILL P--BILLING.PATIENTBILL P, BILLING.PATIENTBILLDETAILS PB
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         --AND P.BILLNO = PB.BILLNO
                         AND P.BILLINGTYPEID = 1
                         AND P.PATIENTSERVICE = 2
                         AND TRUNC(P.BILLDATE) =TRUNC(IN_FROMDATE)
                      UNION ALL
                      SELECT 'OP CASH' PARTICULARS,
                             0,
                             SUM(P.TOTALSERVICEAMOUNT) TOTAL_CASH_AMOUNT_MONTH,
                             0
                        FROM GTT_PATIENTBILL P--BILLING.PATIENTBILL P, BILLING.PATIENTBILLDETAILS PB
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         --AND P.BILLNO = PB.BILLNO
                         AND P.BILLINGTYPEID = 1
                         AND P.PATIENTSERVICE = 2
                         AND TRUNC(P.BILLDATE) BETWEEN TRUNC(IN_MONTHDATE) AND
                             TRUNC(IN_FROMDATE)
                      UNION ALL
                      SELECT 'OP CASH' PARTICULARS,
                             0,
                             0,
                             SUM(P.TOTALSERVICEAMOUNT) TOTAL_CASH_AMOUNT_YEAR
                        FROM GTT_PATIENTBILL P--BILLING.PATIENTBILL P, BILLING.PATIENTBILLDETAILS PB
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         --AND P.BILLNO = PB.BILLNO
                         AND P.BILLINGTYPEID = 1
                         AND P.PATIENTSERVICE = 2
                         AND TRUNC(P.BILLDATE) BETWEEN TRUNC(IN_YEARDATE) AND
                            TRUNC(IN_FROMDATE)
                      UNION ALL
                      SELECT 'IP CASH' PARTICULARS,
                             SUM(P.TOTALSERVICEAMOUNT) TOTAL_CASH_AMOUNT_DAY,
                             0 TOTAL_CASH_AMOUNT_MONTH,
                             0 TOTAL_CASH_AMOUNT_YEAR
                        FROM GTT_PATIENTBILL P--BILLING.PATIENTBILL P, BILLING.PATIENTBILLDETAILS PB
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         --AND P.BILLNO = PB.BILLNO
                         AND P.BILLINGTYPEID = 1
                         AND P.PATIENTSERVICE = 3
                         AND TRUNC(P.BILLDATE) = TRUNC(IN_FROMDATE)
                      UNION ALL
                      SELECT 'IP CASH' PARTICULARS,
                             0,
                             SUM(P.TOTALSERVICEAMOUNT) TOTAL_CASH_AMOUNT_MONTH,
                             0
                        FROM GTT_PATIENTBILL P--BILLING.PATIENTBILL P, BILLING.PATIENTBILLDETAILS PB
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         --AND P.BILLNO = PB.BILLNO
                         AND P.BILLINGTYPEID = 1
                         AND P.PATIENTSERVICE = 3
                         AND TRUNC(P.BILLDATE)  BETWEEN TRUNC(IN_MONTHDATE) AND
                             TRUNC(IN_FROMDATE)
                      UNION ALL
                      SELECT 'IP CASH' PARTICULARS,
                             0,
                             0,
                             SUM(P.TOTALSERVICEAMOUNT) TOTAL_CASH_AMOUNT_YEAR
                        FROM GTT_PATIENTBILL P--BILLING.PATIENTBILL P, BILLING.PATIENTBILLDETAILS PB
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         --AND P.BILLNO = PB.BILLNO
                         AND P.BILLINGTYPEID = 1
                         AND P.PATIENTSERVICE = 3
                         AND TRUNC(P.BILLDATE) BETWEEN TRUNC(IN_YEARDATE) AND
                             TRUNC(IN_FROMDATE)) T1
               GROUP BY PARTICULARS
               Thanks in advance..

    karthick, This is a part of the code.. If I want to calculate other things. Should I need to modify in the same manner or else in the same query it is possible. For your understanding I am pasting the code of the other part with your code replaced.
    select decode(p.patientservice, 2, 'op cash', 3, 'ip cash') particulars,
           sum(
                   case when trunc(p.billdate) = trunc(in_fromdate) then
                            p.totalserviceamount
                        else 0
                   end
              ) a,
           sum(
                   case when trunc(p.billdate) between trunc(in_monthdate) and trunc(in_fromdate) then
                            p.totalserviceamount
                        else 0
                   end
              ) b,
           sum(
                   case when trunc(p.billdate) between trunc(in_yeardate) and trunc(in_fromdate)
                            p.totalserviceamount
                        else 0
                   end
              ) c
      from billing.patientbill p
    where p.locationid    = in_locationid
       adn p.billingtypeid = 1
       and trunc(p.billdate) between trunc(in_yeardate) and trunc(in_fromdate);
    group
        by decode(p.patientservice, 2, 'op cash', 3, 'ip cash');
        UNION ALL
              -----------------TOTAL_CO_CREDIT_AMOUNT--------------------------
              SELECT PARTICULARS,
                     SUM(TOTAL_CO_CREDIT_AMOUNT_DAY) A,
                     SUM(TOTAL_CO_CREDIT_AMOUNT_MONTH) B,
                     SUM(TOTAL_CO_CREDIT_AMOUNT_YEAR) C,
                     1 FLG
                FROM (SELECT 'OP CO CREDIT AMOUNT' PARTICULARS,
                             SUM(P.TOTALSERVICEAMOUNT - P.PATIENTPAIDAMOUNT) TOTAL_CO_CREDIT_AMOUNT_DAY,
                             0 TOTAL_CO_CREDIT_AMOUNT_MONTH,
                             0 TOTAL_CO_CREDIT_AMOUNT_YEAR
                        FROM GTT_PATIENTBILL P
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         AND P.BILLINGTYPEID = 2
                         AND P.DELFLAG=1
                         AND P.PATIENTSERVICE = 2
                         AND TRUNC(P.BILLDATE) = TRUNC(IN_FROMDATE)
                         AND P.PATIENTPAIDAMOUNT <> 0
                      UNION ALL
                      SELECT 'OP CO CREDIT AMOUNT' PARTICULARS,
                             0,
                             SUM(P.TOTALSERVICEAMOUNT - P.PATIENTPAIDAMOUNT) TOTAL_CO_CREDIT_AMOUNT_MONTH,
                             0
                        FROM GTT_PATIENTBILL P
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         AND P.BILLINGTYPEID = 2
                         AND P.DELFLAG=1
                         AND P.PATIENTSERVICE = 2
                         AND TRUNC(P.BILLDATE) BETWEEN TRUNC(IN_MONTHDATE) AND
                             TRUNC(IN_FROMDATE)
                         AND P.PATIENTPAIDAMOUNT <> 0
                      UNION ALL
                      SELECT 'OP CO CREDIT AMOUNT' PARTICULARS,
                             0,
                             0,
                             SUM(P.TOTALSERVICEAMOUNT - P.PATIENTPAIDAMOUNT) TOTAL_CO_CREDIT_AMOUNT_YEAR
                        FROM GTT_PATIENTBILL P
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         AND P.BILLINGTYPEID = 2
                         AND P.DELFLAG=1
                         AND P.PATIENTSERVICE = 2
                         AND TRUNC(P.BILLDATE) BETWEEN TRUNC(IN_YEARDATE) AND
                             TRUNC(IN_FROMDATE)
                         AND P.PATIENTPAIDAMOUNT <> 0
                      UNION ALL
                      SELECT 'IP CO CREDIT AMOUNT' PARTICULARS,
                             SUM(P.TOTALSERVICEAMOUNT - P.PATIENTPAIDAMOUNT) TOTAL_CO_CREDIT_AMOUNT_DAY,
                             0 TOTAL_CO_CREDIT_AMOUNT_MONTH,
                             0 TOTAL_CO_CREDIT_AMOUNT_YEAR
                        FROM GTT_PATIENTBILL P
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         AND P.BILLINGTYPEID = 2
                         AND P.DELFLAG=1
                         AND P.PATIENTSERVICE = 3
                         AND TRUNC(P.BILLDATE) = TRUNC(IN_FROMDATE)
                         AND P.PATIENTPAIDAMOUNT <> 0
                      UNION ALL
                      SELECT 'IP CO CREDIT AMOUNT' PARTICULARS,
                             0,
                             SUM(P.TOTALSERVICEAMOUNT - P.PATIENTPAIDAMOUNT) TOTAL_CO_CREDIT_AMOUNT_MONTH,
                             0
                        FROM GTT_PATIENTBILL P
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         AND P.BILLINGTYPEID = 2
                         AND P.DELFLAG=1
                         AND P.PATIENTSERVICE = 3
                         AND TRUNC(P.BILLDATE) BETWEEN TRUNC(IN_MONTHDATE) AND
                             TRUNC(IN_FROMDATE)
                         AND P.PATIENTPAIDAMOUNT <> 0
                      UNION ALL
                      SELECT 'IP CO CREDIT AMOUNT' PARTICULARS,
                             0,
                             0,
                             SUM(P.TOTALSERVICEAMOUNT - P.PATIENTPAIDAMOUNT) TOTAL_CO_CREDIT_AMOUNT_YEAR
                        FROM GTT_PATIENTBILL P
                       WHERE P.LOCATIONID = IN_LOCATIONID
                         AND P.BILLINGTYPEID = 2
                         AND P.DELFLAG=1
                         AND P.PATIENTSERVICE = 3
                         AND TRUNC(P.BILLDATE) BETWEEN TRUNC(IN_YEARDATE) AND
                             TRUNC(IN_FROMDATE)
                         AND P.PATIENTPAIDAMOUNT <> 0) T5
               GROUP BY PARTICULARS
              UNION ALL
       

  • I NEED HELP PLZZZ!!!

    Hiiiiiiii....
    i'm trying to write a program which converts colored images to gayscale and saves them.The onle problem is that when i convert them they get to be so dark unlike when i try to do it with photoshop..
    can anyone help me plzzzz...
    i really neeeed someones help.
    This is what i have come up with.. plzz if anyone has better solution or can correct mine i'ld be really thankful.
    public static void writeImage(String fn, byte[] data, int width, int height)throws FileNotFoundException, IOException {
    FileOutputStream fOut = new FileOutputStream(fn);
    JPEGImageEncoder jpeg_encode = JPEGCodec.createJPEGEncoder(fOut);
    int ints[] = new int[data.length];
    for (int i = 0; i< data.length; i++){
    ints[i] = 255 << 24 |
    (int) (data[i] & 0xff) <<16 |
    (int) (data[i] & 0xff) << 8 |
    (int) (data[i] & 0xff);
    BufferedImage image = new BufferedImage(100,100,
    BufferedImage.TYPE_BYTE_GRAY);
    image.setRGB(0,0,width,height,ints,0,width);
    jpeg_encode.encode(image);
    fOut.close();
    where data=jpgFile.getBytes();
    note:i don't want the images just to look like grayscale i really want them to be grayscale so when i use an if statement like:
    if(image.getType() == BufferedImage.TYPE_BYTE_GRAY)it would work.
    thanxxxxxxxxxxxxxxxxxxxxxxxxxx

    for (int i = 0; i< data.length; i++){
    ints[i] = 255 << 24 |I think you can just leave the alpha channel at zero. Anyway...
    (int) (data[i] & 0xff) <<16 |
    (int) (data[i] & 0xff) << 8 |
    (int) (data[i] & 0xff);
    }OK, what you're doing here is taking the blue channel and copying it to red and green. The result's grayscale, sure, but it's probably not what you want.
    Instead, take the red, green and blue and average them. Then put that averaged value into all 3 channels. Something like...
    gray = (int)((
    (data[i] & 0xff0000) >>16 |
    (data[i] & 0xff00) >>8 |
    (data[i] & 0xff) ) /3);
    ints[i] = (int) (gray) <<16 |
    (int) (gray) << 8 |
    (int) (gray);
    note:i don't want the images just to look like
    grayscale i really want them to be grayscale so when iIf the red green and blue are the same, it's grayscale...
    Hope that helps.

  • Need Video HELP PLZZZ!!!

    Ok, so i got a music video from iTunes music store and put it on my iPod. When i went to watch it it jus played like any other music song would, no video jus the song and i am clueless on why its doing it???? Help plz.
    WoWAddict44

    This can happen if you play from the music or playlist menu. On the pod select video, then the video and then play. If this doesn't work, post back.

  • Guys help plzzz....urgent!!!!!!

    I am calling a servlet in the
    C:\jakarta-tomcat-4.1.18\webapps\examples\WEB-INF\classes\combined
    I am calling a particular servlet "NewUserServlet" stored in this directory from form action in html file
    <form action="http://localhost:8080/examples/servlet/combined.NewUserServlet"
    method="post" target="_top">
    But eventually, when the servlet is called, it gives
    type: Status report
    message: Servlet invoker is currently unavailable
    description :The requested service (Servlet invoker is currently unavailable) is not currently available.
    can you guys suggest, why this may happen? I have already made changes in the web.xml file in conf/ directory
    I have uncommented the servlet-mapping element in the web.xml file.
    Plz suggest!

    in newer tomcat versions the serlvet invoker is deisabled by default (in my opinionen that's good).
    Just create your own app dir under WEB-INF an place your Servlet in there, the you can use your servlet without the servlet invoker (may you need ot search this forum to learn how to deploy you own app).

  • Date Format problem in a JTable, help plzzz !!!

    Hi,
    i have a JTable which contains multiple date columns, and more particulary, Timestamp columns.
    I mean this format : yyyy-mm-dd hh:mm:ss.fffffffff
    I only need hh:mm:ss informations for my JTable.
    The problem is when i retrieve the datas in the JTable (which has a bean Select for model), the date column has this format : yyyy-mm-dd (only the date), and the time is not present !
    What must i do to have only a part of the timestamp data in the column ??
    Thanks in advance
    Steve

    If you want to format data in any way other than the default in a JTable, you need a table cell renderer. Sun's tutorial on how to use JTables explains them.

  • Need Help PLzzz

    when i turn my ipod on it makes a ticking noise and the sad face shows up. i tried doing everything on the website but nothing happens. when i get into disk mode i plug it in and it does it all over agian. it doesnt show up on disk mangement eihter. anyone know what to do?

    does that webiste really fix the ipod?

  • N91 restarting itself, HELP PLZZZ

    ive gotta n91, bought in Russia,
    when im making a video call, in 20seconds its restarting itself, or when surfing over fast internet.
    i tried to update the software,which is right now:
    v2.10.013
    15-09-06
    rm-43
    N91 (05.01)
    can anyone tell me how to fix this problem???

    16-Mar-2007
    03:25 PM
    shayesta wrote:
    Flash it version 2.20.008 thats the latest version.
    Bro, I knew mine is 2.10.013 is the latest.
    Are y sure 2.20 has out or the person is right who is sayin' a new FW is comin????
    Well, many have 2.10.013 and I SWEAR I HAVE NEVER HARD THIS TYPE OF PROBLEM.
    Do the above mentioned things, then tell us.

Maybe you are looking for