1 Replies - 8004 Views - Last Post: 16 September 2008 - 07:24 PM Rate Topic: -----

#1 p4cm4n  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-September 08

NEED HELP: how do i convert this pseudocode to visual basic

Posted 15 September 2008 - 09:14 AM

Im new to programming and need some help with a school project. My questions are included as comments in the attached code.
I have also attached a screenshot of the form.

Posted Image

Dim Dday As String
Dim Wweek As String
Dim CurrentMonth As String

' Creating a program which converts a letter into a certain day, week, and month. A business works a 24-day month: i.e. four weeks Monday to Saturday, and the cleaning day is currently identified by using a letter of the alphabet. For example, A is Monday Week 1, B is Tuesday Week 1, and so on down to X which is Saturday Week 4.

Private Sub cmdConvert_Click()

'Need to figure out what goes here............................ in visual basic language

'my project sheet provides pseudocode of


'Code<-- ""
'Day<-- ""
'Week<-- ''"
'CurrentDate <-- ""
'MonthNumber<-- 0

'READ Code

' CALL ConvertToDay(Code,Day)
' CALL ConvertToWeek(Code,Week)
' CALL GetCurrentMonth(Current,Month)


'PRINT Day, Week, CurrentMonth
'End Main

' Is there a function similar to this CALL function which i could use in visual basic, in order to retrieve data from the three modules ConvertToDay, ConvertToWeek, and GetCurrentMonth so that a cleaning day code is converted into its correct day, week, and month. Does anyone know how to convert this pseudocode into a visual basic code format so that the letter that it entered into the text box will be converted properly? 

End Sub

Sub ConvertToDay(Dday As String)
Dday = txtCode.Text
 Case Letter

	Case "A", "a", "G", "g", "M", "m", "M", "s": Dday = "Monday"
	Case "B", "b", "H", "h", "N", "n", "T", "t": Dday = "Tuesday"
	Case "C", "c", "I", "i", "O", "o", "U", "u": Dday = "Wednesday"
	Case "D", "d", "J", "j", "P", "p", "V", "v": Dday = "Thursday"
	Case "E", "e", "K", "k", "Q", "q", "W", "w": Dday = "Friday"
	Case "F", "f", "L", "l", "R", "r", "X", "x": Dday = "Saturday"
	Case Else: Dday = "Invalid"

End Select
End Sub

Sub ConvertToWeek(Wweek As String)

Wweek = txtCode.Text

Select Case Letter

	Case "A", "a", "B", "b", "C", "c", "D", "d", "E", "e", "F", "f": Wweek = "Week 1"
	Case "G", "g", "H", "h", "I", "i", "J", "j", "K", "k", "L", "l": Wweek = "Week 2"
	Case "M", "m", "N", "n", "O", "o", "P", "p", "Q", "q", "R", "r": Wweek = "Week 3"
	Case "S", "s", "T", "t", "U", "u", "V", "v", "W", "w", "X", "x": Wweek = "Week 4"
	Case Else: Wweek = "Invalid"
End Select
End Sub

Sub GetCurrentMonth(Mmonth As String)

		'Uses the Now Function to return the current time and date from the computer
		CurrentDate = Now
		'Converts the current date to a number representing the month
		MonthNumber = Month(CurrentDate)
		'Converts the month number to the actual month name
		Select Case MonthNumber
			   Case 1: Mmonth = "January"
			   Case 2: Mmonth = "February"
			   Case 3: Mmonth = "March"
			   Case 4: Mmonth = "April"
			   Case 5: Mmonth = "May"
			   Case 6: Mmonth = "June"
			   Case 7: Mmonth = "July"
			   Case 8: Mmonth = "August"
			   Case 9: Mmonth = "September"
			   Case 10: Mmonth = "October"
			   Case 11: Mmonth = "November"
			   Case 12: Mmonth = "December"
			   lblMonthDisplay.ForeColor = &HFF00&
			   lblMonthDisplay.Caption = Mmonth
			   Case Else: Mmonth = "INVALID CODE"
			   lblMonthDisplay.ForeColor = &HFF&
			   lblMonthDisplay.Caption = Mmonth
		End Select
End Sub

This post has been edited by p4cm4n: 15 September 2008 - 10:43 PM

Is This A Good Question/Topic? 0
  • +

Replies To: NEED HELP: how do i convert this pseudocode to visual basic

#2 thava  Icon User is offline

  • D.I.C Lover
  • member icon

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

Re: NEED HELP: how do i convert this pseudocode to visual basic

Posted 16 September 2008 - 07:24 PM

i think you miss the tuesday if you add these here is code here
Public Function Convertday(st As String) As String
	st = UCase(st)
	dy = Asc(st)
	Convertday = Format(dy - 1, "dddd")
End Function

Public Function ConvertWeek(st As String) As String
Dim i As Integer
	st = UCase(st)
	dy = Asc(st)
	 i = (dy - 5) Mod 30
	Select Case (i \ 7)
	Case 0:
	ConvertWeek = "week1"
	Case 1:
	ConvertWeek = "week2"
	Case 2:
	ConvertWeek = "week3"
	Case 3:
	ConvertWeek = "week4"
	Case 4:
	ConvertWeek = "week3"
	End Select	
End Function

and just add the current month
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1