neew help with mscomm and ascii conversion...
'Modified by oto45
Option Explicit
'Keeps track of x and y coordinates
Dim CurX As Integer, CurY As Integer
'Array of points
Dim Pointarray() As Integer
'Constants make code easier to read
Const XDist = 1
Const YDist = 0
'size of the array
Const SizeOfArray = 11
'randomness of the terrain
Dim Randomness As Single
'number of loops to refine terrain
Dim Loops As Integer
Dim strdata As String
'more symbolic constants
Const RandLimit = 10
Const Draw = 10
Private Sub Command1_Click()
'Build a mountain
Dim X As Integer
Dim Y As Integer
Dim i As Long
Dim FName As String
Dim Buf As String
Dim strdata As String
'resize the array according to size variables
Erase Pointarray
ReDim Pointarray(0 To SizeOfArray, 0 To SizeOfArray)
Do
Call waitscan
'Do While MSComm1.InBufferCount <> 0 'wait for the buffer to start filling
For X = 0 To SizeOfArray - 1
For Y = 0 To SizeOfArray - 1
Dim temp
MSComm1.InputLen = 1 'Read buffer one character at a time
strdata = MSComm1.Input 'move data from input to strdata
If strdata <> Chr(13) Then
With Text1
.SelStart = Len(.Text)
.SelText = strdata 'use this to add lines on a text box
End With
strdata = 0
ElseIf strdata = Chr(13) Then 'look for chr(13) then write a vbcrlf
temp = vbCrLf
With Text1
.SelStart = Len(.Text)
.SelText = temp
End With
strdata = 0
End If
'------------------------
'strdata = MSComm1.Input 'working
'Buf = Trim(strdata) 'trim off extra spaces
'If Buf <> "" Then
'Text1 = ""
'Dim v As Integer
'For v = 1 To Len(Buf)
'Text1 = Text1 & " " & Asc(Mid(Buf, v, 1))
'Next
'------------------------
Text1 = Asc(strdata)
Pointarray(X, Y) = Text1
'End If
Next Y
Next X
'Loop
strdata = 0
With Graph3D
.ClearGraph
.AddElement
.Caption = "Light Intensity"
.ElementType(0) = 3 'Draw Surface
.TrackMode = 2
.XGridNumber = 11
.YGridNumber = 255
.ZGridNumber = 11
Dim ti, tj, j, z
For X = 0 To 11
For Y = 0 To 11
.PlotXYZ X, Pointarray(X, Y), Y, 0
Next
Next
'For i = 0 To 41
'ti = (i - 20#) / 20# * 3.15
'For j = 0 To 41
'tj = (j - 20#) / 20# * 3.15
'X = (Cos(tj) + 3#) * Cos(ti)
'Y = Sin(tj)
'z = (Cos(tj) + 3#) * Sin(ti)
'.PlotXYZ X, Y, z, 0
'Next
'Next
.SetRange 0, 11, 0, 255, 0, 11
End With
Loop Until MSComm1.PortOpen = False
End Sub
Public Sub waitscan()
Do While MSComm1.InBufferCount = 0 'wait for the buffer to start filling
DoEvents
Loop
End Sub
Public Sub showinput()
Dim temp
MSComm1.InputLen = 1
strdata = MSComm1.Input
If strdata <> Chr(13) Then 'Read buffer one character at a time
With Text1 'move data from input to strdata
.SelStart = Len(.Text)
.SelText = strdata 'use this to add lines on a text box
End With
strdata = 0
ElseIf strdata = Chr(13) Then 'look for chr(13) then write a vbcrlf
temp = vbCrLf
With Text1
.SelStart = Len(.Text)
.SelText = temp
End With
strdata = 0
End If
End Sub
Private Sub Command2_Click()
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
Graph3D.ClearGraph
End Sub
Private Sub Command4_Click()
MSComm1.CommPort = 2
MSComm1.settings = "9600, n, 8, 1"
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
End Sub

